public function getCheckout($metaUser, $counter = 0, $InvoiceFactory = null) { $c = array(); $totalcost = 0; if (empty($this->content)) { return array(); } $return = array(); foreach ($this->content as $cid => $content) { // Cache items if (!isset($c[$content['type']][$content['id']])) { switch ($content['type']) { case 'plan': $obj = new SubscriptionPlan(); $obj->load($content['id']); $o = array(); $o['obj'] = $obj; $o['name'] = $obj->getProperty('name'); $o['desc'] = $obj->getProperty('desc'); $terms = $obj->getTermsForUser(false, $metaUser); if ($counter) { $terms->incrementPointer($counter); } $o['terms'] = $terms; $o['cost'] = $terms->nextterm->renderCost(); $c[$content['type']][$content['id']] = $o; break; } } $entry = array(); $entry['obj'] = $c[$content['type']][$content['id']]['obj']; $entry['fullamount'] = $c[$content['type']][$content['id']]['cost']; $entry['name'] = $c[$content['type']][$content['id']]['name']; $entry['desc'] = $c[$content['type']][$content['id']]['desc']; $entry['terms'] = $c[$content['type']][$content['id']]['terms']; $item = array('item' => array('obj' => $entry['obj']), 'terms' => $entry['terms']); if (!empty($content['coupons'])) { $cpsh = new couponsHandler($metaUser, false, $content['coupons']); $item = $cpsh->applyAllToItems(0, $item); $entry['terms'] = $item['terms']; } $entry['cost'] = $entry['terms']->nextterm->renderTotal(); if ($entry['cost'] > 0) { $total = $content['quantity'] * $entry['cost']; $entry['cost_total'] = AECToolbox::correctAmount($total); } else { $entry['cost_total'] = AECToolbox::correctAmount('0.00'); } if ($entry['cost_total'] == '0.00') { $entry['free'] = true; } else { $entry['free'] = false; } $entry['cost'] = AECToolbox::correctAmount($entry['cost']); $entry['quantity'] = $content['quantity']; $totalcost += $entry['cost_total']; $return[$cid] = $entry; } if (!empty($this->params['overall_coupons'])) { $cpsh = new couponsHandler($metaUser, $InvoiceFactory, $this->params['overall_coupons']); $totalcost_ncp = $totalcost; $totalcost = $cpsh->applyToAmount($totalcost); } else { $totalcost_ncp = $totalcost; } // Append total cost $return[] = array('name' => '', 'count' => '', 'cost' => AECToolbox::correctAmount($totalcost_ncp), 'cost_total' => AECToolbox::correctAmount($totalcost), 'is_total' => true, 'obj' => false); return $return; }