$properties = array(); $properties['showcheckout'] = false; // Do not let the user in without a subscription or at least an invoice if (!$metaUser->hasSubscription && empty($invoiceno)) { subscribe($option); return; } elseif (!$metaUser->hasSubscription && !empty($invoiceno)) { $properties['showcheckout'] = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid); } // Prepare Main Tabs $tabs = array(); foreach (array('overview', 'invoices') as $fname) { $tabs[$fname] = JText::_(strtoupper('aec_subdetails_tab_' . $fname)); } // If we have a cart, we want to link to it $cart = aecCartHelper::getCartbyUserid($metaUser->userid); $properties['hascart'] = $cart->id; $properties['alert'] = $metaUser->getAlertLevel(); // Load a couple of basic variables $subscriptions = array(); $pplist = array(); $excludedprocs = array('free', 'error'); $custom = null; $mi_info = null; // Start off the processor list with objSubscription if (!empty($metaUser->objSubscription->type)) { $pplist = array($metaUser->objSubscription->type); } // The upgrade button might only show on some occasions $properties['upgrade_button'] = true; if (!empty($tmpl->cfg['renew_button_never'])) {
* @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version */ // Dont allow direct linking defined('_JEXEC') or die('Direct Access to this location is not allowed.'); require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php'; $class_sfx = $params->get('moduleclass_sfx', ""); $pretext = $params->get('pretext'); $posttext = $params->get('posttext'); $mode = $params->get('mode', 'abridged'); $button = $params->get('button', 1); $user = JFactory::getUser(); if ($user->id) { $lang = JFactory::getLanguage(); $lang->load('mod_acctexp_cart', JPATH_SITE); $c = aecCartHelper::getCartbyUserid($user->id); $metaUser = new metaUser($user->id); $cart = $c->getCheckout($metaUser); if (empty($c->content)) { require JModuleHelper::getLayoutPath('mod_acctexp_cart', $params->get('layout', 'empty')); } else { switch ($mode) { default: case 'abridged': $quantity = 0; $total = 0; foreach ($cart as $bid => $bitem) { if (!empty($bitem['obj'])) { $quantity += $bitem['quantity']; } else { $total = $bitem['cost_total'];
public function getTopPlan() { return aecCartHelper::getFirstSortedCartItemObject($this); }
public function create($intro = 0, $usage = 0, $group = 0, $processor = null, $invoice = 0, $autoselect = false) { global $aecConfig; $register = !$this->loadMetaUser(true); $this->getPassthrough(); // Reset $register if we seem to have all data if ($register && !empty($this->passthrough['username']) || !empty($aecConfig->cfg['skip_registration'])) { $register = 0; } if ($intro && $this->metaUser->hasSubscription && !$aecConfig->cfg['customintro_always']) { $intro = false; } if (empty($this->usage) && empty($group) && !$intro && !empty($aecConfig->cfg['customintro'])) { if (!empty($aecConfig->cfg['customintro_userid'])) { aecRedirect($aecConfig->cfg['customintro'], $this->userid, "aechidden"); } else { aecRedirect($aecConfig->cfg['customintro']); } } $this->recurring = aecGetParam('recurring', null); $planlist = new SubscriptionPlanList($usage, $group, $this->metaUser, $this->recurring); $nochoice = false; // There is no choice if we have only one group or only one item with one payment option if (count($planlist->list) === 1) { if ($planlist->list[0]['type'] == 'item') { if (count($planlist->list[0]['gw']) === 1) { $nochoice = true; } elseif (!empty($processor)) { foreach ($planlist->list[0]['gw'] as $gw) { if ($gw->processor_name == $processor) { $nochoice = true; } } if ($nochoice) { $first = 0; foreach ($planlist->list[0]['gw'] as $gwid => $gw) { if ($gw->processor_name != $processor) { unset($planlist->list[0]['gw'][$gwid]); } else { $first = $gwid; } } if (!empty($first)) { $planlist->list[0]['gw'][0] = $planlist->list[0]['gw'][$first]; unset($planlist->list[0]['gw'][$first]); } } } } else { // Jump back and use the only group we've found return $this->create($intro, 0, $planlist->list[0]['id'], null, 0, true); } } // If we have only one processor on one plan, there is no need for a decision if ($nochoice && !($aecConfig->cfg['show_fixeddecision'] && empty($processor))) { // If the user also needs to register, we need to guide him there after the selection has now been made if ($register && empty($aecConfig->cfg['skip_registration'])) { aecRegistration::registerRedirect($intro, $planlist->list[0]); } else { // Existing user account - so we need to move on to the confirmation page with the details $this->usage = $planlist->list[0]['id']; if (isset($planlist->list[0]['gw'][0]->recurring)) { $this->recurring = $planlist->list[0]['gw'][0]->recurring; } else { $this->recurring = 0; } $this->processor = $planlist->list[0]['gw'][0]->processor_name; if ($invoice != 0 && !is_null($invoice)) { $this->invoice_number = $invoice; } return $this->confirm(); } } if ($group) { $g = new ItemGroup(); $g->load($group); $planlist->list['group'] = ItemGroupHandler::getGroupListItem($g); } $cart = $this->userid ? aecCartHelper::getCartidbyUserid($this->userid) : false; $selected = (!empty($group) || !empty($usage)) && !$autoselect; if (!$selected && !empty($planlist->list['group'])) { unset($planlist->list['group']); } $passthrough = $this->getPassthrough(); $csslist = $planlist->addButtons($register, $passthrough); return getView('plans', array('userid' => $this->userid, 'list' => $planlist->list, 'passthrough' => $passthrough, 'register' => $register, 'cart' => $cart, 'selected' => $selected, 'group' => $group, 'csslist' => $csslist)); }
public function checkoutProcess($int_var = null, $metaUser = null, $plan = null, $InvoiceFactory = null, $cart = null) { if (empty($this->settings)) { $this->getSettings(); } if (isset($int_var['planparams']['aec_overwrite_settings'])) { if (!empty($int_var['planparams']['aec_overwrite_settings'])) { $this->exchangeSettingsByPlan(null, $int_var['planparams']); } } if (empty($plan) && !empty($cart)) { $plan = aecCartHelper::getFirstCartItemObject($cart); } $request = new stdClass(); $request->parent =& $this; $request->int_var =& $int_var; $request->metaUser =& $metaUser; $request->plan =& $plan; $request->invoice =& $InvoiceFactory->invoice; $request->items =& $InvoiceFactory->items; $request->cart =& $cart; return $this->processor->checkoutProcess($request, $InvoiceFactory); }