$wallPosters = array("id" => "wall-posters", "quantity" => $_GET['wallposters-quantity']); array_push($addons, $wallPosters); } /* * Adding addon2 to the addons array, if it is set by user. */ if (isset($_GET['ebook']) && $_GET['ebook'] != "") { $ebook = array("id" => "e-book"); array_push($addons, $ebook); } /* * Adding subscription and addons params to the create subscription estimate request */ $params = array("subscription" => $subParams); $params["addons"] = $addons; $result = ChargeBee_Estimate::createSubscription($params); $estimate = $result->estimate(); } catch (ChargeBee_InvalidRequestException $e) { /* * Checking whether the error is due to coupon param. If the error is due to * coupon param then reason for error can be identified through "api_error_code" attribute. */ if ($e->getParam() == "subscription[coupon]") { handleCouponErrors($e); } else { handleInvalidRequestErrors($e, array("subscription[plan_id]", "addons[id][0]", "addons[id][1]")); } return; } catch (Exception $e) { handleGeneralErrors($e); return;
<?php $estimatParam = array("subscription" => array("id" => $subscriptionId)); $estimate = ChargeBee_Estimate::updateSubscription($estimatParam)->estimate(); ?> <div class="clearfix col-sm-12"> <ul id="cb-order-summary" class="list-unstyled"> <?php foreach ($estimate->lineItems as $li) { ?> <li> <div class="row"> <div class="col-xs-8"> <span class="cb-list-prefix"><?php echo $li->entityType; ?> :</span> <strong> <?php echo esc($li->description) . " ( x " . esc($li->quantity) . ")"; ?> </strong> </div> <div class="col-xs-4 text-right">$ <?php echo number_format($li->amount / 100, 2, '.', ''); ?> </div> </div> </li> <?php }