/** * constructor */ function __construct() { parent::__construct(); $app = JFactory::getApplication(); $app->redirect("index.php?option=com_tienda&view=countries"); return; }
/** * Displays item * @return void */ function view($cachable = false, $urlparams = false) { $model = $this->getModel($this->get('suffix')); $model->getId(); $row = $model->getItem(); if (version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.6+ code here if (empty($row->enabled)) { $table = $model->getTable(); $table->load($row->id); $table->enabled = 1; if ($table->save()) { $redirect = "index.php?option=com_tienda&view=" . $this->get('suffix') . "&task=view&id=" . $model->getId(); $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect); return; } } } else { // Joomla! 1.5 code here if (empty($row->published)) { $table = $model->getTable(); $table->load($row->id); $table->published = 1; if ($table->save()) { $redirect = "index.php?option=com_tienda&view=" . $this->get('suffix') . "&task=view&id=" . $model->getId(); $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect); return; } } } parent::view($cachable, $urlparams); }
/** * (non-PHPdoc) * @see tienda/admin/TiendaController#display($cachable) */ function display($cachable = false, $urlparams = '') { if (empty(JFactory::getUser()->id)) { $url = JRoute::_("index.php?option=com_tienda&view=orders"); Tienda::load("TiendaHelperUser", 'helpers.user'); $redirect = JRoute::_(TiendaHelperUser::getUserLoginUrl($url), false); JFactory::getApplication()->redirect($redirect); return; } $model = $this->getModel($this->get('suffix')); $this->_setModelState(); $config = Tienda::getInstance(); $model->setState('filter_orderstates', $config->get('orderstates_csv', '2, 3, 5, 17')); $list = $model->getList(); $view = $this->getView('orders', 'html'); $view->set('_controller', 'orders'); $view->set('_view', 'orders'); $view->set('_doTask', true); $view->set('hidemenu', false); $view->setModel($model, true); $view->setLayout('view'); JRequest::setVar('view', $this->get('suffix')); JRequest::setVar('layout', 'default'); parent::display($cachable, $urlparams); }
/** * Saves an item and redirects based on task * @return void */ function save() { if (!($row = parent::save())) { return $row; } $model = $this->getModel($this->get('suffix')); $error = false; $row->category_description = JRequest::getVar('category_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $fieldname = 'category_full_image_new'; $userfile = JRequest::getVar($fieldname, '', 'files', 'array'); if (!empty($userfile['size'])) { if ($upload = $this->addfile($fieldname)) { $row->category_full_image = $upload->getPhysicalName(); } else { $error = true; } } if ($row->save()) { $model->setId($row->id); $this->messagetype = 'message'; $this->message = JText::_('COM_TIENDA_SAVED'); if ($error) { $this->messagetype = 'notice'; $this->message .= " :: " . $this->getError(); } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onAfterSave' . $this->get('suffix'), array($row)); } else { $this->messagetype = 'notice'; $this->message = JText::_('COM_TIENDA_SAVE_FAILED') . " - " . $row->getError(); } }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.created_datetime', 'cmd'); $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word'); $state['filter_orderid'] = $app->getUserStateFromRequest($ns . 'filter_orderid', 'filter_orderid', '', ''); $state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', ''); $state['filter_transaction'] = $app->getUserStateFromRequest($ns . 'filter_transaction', 'filter_transaction', '', ''); $state['filter_user'] = $app->getUserStateFromRequest($ns . 'filter_user', 'filter_user', '', ''); $state['filter_userid'] = $user_id = JFactory::getUser()->id; $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', ''); $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', ''); $state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', ''); $state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', ''); $state['filter_datetype'] = 'created'; $state['filter_total_from'] = $app->getUserStateFromRequest($ns . 'filter_total_from', 'filter_total_from', '', ''); $state['filter_total_to'] = $app->getUserStateFromRequest($ns . 'filter_total_to', 'filter_total_to', '', ''); $state['filter_enabled'] = $app->getUserStateFromRequest($ns . 'filter_enabled', 'filter_enabled', '', ''); $state['filter_lifetime'] = $app->getUserStateFromRequest($ns . 'filter_lifetime', 'filter_lifetime', '', ''); foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
public function display($cachable = false, $urlparams = false) { $session = JFactory::getSession(); $session->clear('tienda.opc.method'); $session->clear('tienda.opc.billingAddress'); $session->clear('tienda.opc.shippingAddress'); $session->clear('tienda.opc.shippingRates'); $session->clear('tienda.opc.shippingMethod'); $session->clear('tienda.opc.userCoupons'); $session->clear('tienda.opc.userCredit'); $session->clear('tienda.opc.requireShipping'); if (!$this->user->id) { $session->set('old_sessionid', $session->getId()); } $view = $this->getView($this->get('suffix'), 'html'); $view->setTask(true); $order = $this->_order; $order = $this->populateOrder(); $view->assign('order', $order); $view->assign('user', $this->user); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('addresses', 'TiendaModel'); $model->setState("filter_userid", $this->user->id); $model->setState("filter_deleted", 0); $addresses = $model->getList(); $view->assign('addresses', $addresses); $view->setModel($model); $showShipping = $order->isShippingRequired(); $view->assign('showShipping', $showShipping); $session->set('tienda.opc.requireShipping', serialize($showShipping)); $view->assign('default_country', $this->default_country); $view->assign('default_country_id', $this->default_country_id); TiendaController::display($cachable, $urlparams); }
/** * Loads view for assigning entities to attributes * * @return unknown_type */ function selectentities() { $type = JRequest::getVar('eaventity_type', 'products'); $this->set('suffix', $type); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); foreach (@$state as $key => $value) { $model->setState($key, $value); } $id = JRequest::getVar('id', JRequest::getVar('id', '0', 'post', 'int'), 'get', 'int'); $row = $model->getTable('eavattributes'); $row->load($id); $view = $this->getView('eavattributes', 'html'); $view->set('_controller', 'eavattributes'); $view->set('_view', 'eavattributes'); $view->set('_action', "index.php?option=com_tienda&controller=eavattributes&task=selectentities&tmpl=component&eaventity_type={$type}&id=" . $model->getId()); $view->setModel($model, true); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('select' . $type); $view->setTask(true); $view->display(); }
/** * delete the object and updates the product quantities */ function delete() { $this->message = ''; $this->messagetype = ''; $error = false; $cids = JRequest::getVar('cid', array(0), 'request', 'array'); // Get the ProductQuantities model $qmodel = JModel::getInstance('ProductQuantities', 'TiendaModel'); // Filter the quantities $qmodel->setState('filter_attributes', implode(',', $cids)); $quantities = $qmodel->getList(); $qtable = $qmodel->getTable(); // Delete the product quantities foreach (@$quantities as $q) { if (!$qtable->delete($q->productquantity_id)) { $this->message .= $qtable->getError(); $this->messagetype = 'notice'; $error = true; } } if ($error) { $this->message = JText::_('COM_TIENDA_ERROR') . " - " . $this->message; } else { $this->message = JText::_('COM_TIENDA_ITEMS_DELETED'); } // delete the option itself parent::delete(); }
/** * Loads view for assigning products to coupons * * @return unknown_type * @enterprise */ function selectproducts() { $this->set('suffix', 'products'); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['filter_category'] = $app->getUserStateFromRequest($ns . 'category', 'filter_category', '', ''); foreach (@$state as $key => $value) { $model->setState($key, $value); } $id = JRequest::getInt('id', 0); $row = $model->getTable('coupons'); $row->load($id); $view = $this->getView('coupons', 'html'); $view->set('_controller', 'coupons'); $view->set('_view', 'coupons'); $view->set('_action', "index.php?option=com_tienda&controller=coupons&task=selectproducts&tmpl=component&id=" . $id); $view->setModel($model, true); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('selectproducts'); $view->setTask(true); JRequest::setVar('hidemainmenu', '1'); $view->display(); }
/** * (non-PHPdoc) * @see tienda/tienda/site/TiendaController::display() */ function display($cachable = false, $urlparams = false) { $this->hidefooter = true; $object = JRequest::getVar('object'); $view = $this->getView($this->get('suffix'), 'html'); $view->assign('object', $object); $view->setTask(true); parent::display($cachable, $urlparams); }
/** * @return void */ function edit() { $model = $this->getModel($this->get('suffix')); $row = $model->getTable(); $row->load(array('user_id' => JFactory::getUser()->id)); JRequest::setVar('id', $row->user_info_id); JRequest::setVar('view', 'accounts'); JRequest::setVar('layout', 'form'); parent::display(); }
/** * constructor */ function __construct() { if (empty(JFactory::getUser()->id)) { $url = JRoute::_("index.php?option=com_tienda&view=dashboard"); Tienda::load("TiendaHelperUser", 'helpers.user'); $redirect = JRoute::_(TiendaHelperUser::getUserLoginUrl($url), false); JFactory::getApplication()->redirect($redirect); return; } parent::__construct(); $this->set('suffix', 'dashboard'); }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['filter_userid'] = $app->getUserStateFromRequest($ns . 'filter_userid', 'filter_userid', '', ''); $state['filter_user'] = $app->getUserStateFromRequest($ns . 'filter_user', 'filter_user', '', ''); $state['filter_address'] = $app->getUserStateFromRequest($ns . 'filter_address', 'filter_address', '', ''); foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $model = $this->getModel($this->get('suffix')); $user = JFactory::getUser(); $state['filter_user'] = $user->id; if (empty($user->id)) { $session = JFactory::getSession(); $state['filter_session'] = $session->getId(); } foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', ''); $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', ''); $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', ''); $state['filter_code'] = $app->getUserStateFromRequest($ns . 'code', 'filter_code', '', ''); foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
/** * Displays search results * * (non-PHPdoc) * @see tienda/admin/TiendaController#display($cachable) */ function display($cachable = false, $urlparams = false) { JRequest::setVar('view', $this->get('suffix')); $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType()); $model = $this->getModel($this->get('suffix')); $this->_setModelState(); if ($items = $model->getList()) { foreach ($items as $row) { $row->category_id = 0; $categories = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getCategories($row->product_id); if (!empty($categories)) { $row->category_id = $categories[0]; } $itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->product($row->product_id, $row->category_id, true); $row->itemid = empty($itemid) ? JRequest::getInt('Itemid') : $itemid; } } parent::display($cachable, $urlparams); }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', ''); $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', ''); $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', ''); $state['filter_username'] = $app->getUserStateFromRequest($ns . 'username', 'filter_username', '', ''); $state['filter_email'] = $app->getUserStateFromRequest($ns . 'email', 'filter_email', '', ''); $state['filter_group'] = $app->getUserStateFromRequest($ns . 'filter_group', 'filter_group', '', ''); if (Tienda::getInstance()->get('display_subnum', 0)) { $state['filter_subnum'] = $app->getUserStateFromRequest($ns . 'filter_subnum', 'filter_subnum', '', ''); } foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'c.country_name', 'cmd'); $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', ''); $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', ''); $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', ''); $state['filter_code'] = $app->getUserStateFromRequest($ns . 'code', 'filter_code', '', ''); $state['filter_countryid'] = $app->getUserStateFromRequest($ns . 'countryid', 'filter_countryid', '', ''); foreach (@$state as $key => $value) { $model->setState($key, $value); } $query = $model->getQuery(); $query->order('tbl.zone_name'); $model->setQuery($query); return $state; }
/** * Sets the model's state * * @return array() */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $session = JFactory::getSession(); $user = JFactory::getUser(); $state['filter_user'] = $user->id; if (empty($user->id)) { $state['filter_session'] = $session->getId(); } Tienda::load('TiendaHelperUser', 'helpers.user'); $filter_group = TiendaHelperUser::getUserGroup($user->id); $state['filter_group'] = $filter_group; foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
/** * * @return unknown_type */ function _setModelState() { $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $config = Tienda::getInstance(); // adjust offset for when filter has changed if ($app->getUserState($ns . 'product_id') != $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', '')) { $state['limitstart'] = '0'; } $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.productdownload_startdate', 'cmd'); $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word'); $state['filter_product_id'] = $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', 'integer'); $state['filter_user'] = JFactory::getUser()->id; $state['filter'] = $app->getUserStateFromRequest($ns . 'filter', 'filter', '', 'word'); foreach (@$state as $key => $value) { $model->setState($key, $value); } return $state; }
public function display($cachable = false, $urlparams = false) { $model = $this->getModel($this->get('suffix')); $state = $model->getState(); $state->stats_interval = JRequest::getVar('stats_interval', 'last_thirty'); $model->setState('stats_interval', $state->stats_interval); $cache = JFactory::getCache('com_tienda'); $cache->setCaching(true); $cache->setLifeTime('900'); $orders = $cache->call(array($model, 'getOrdersChartData'), $state->stats_interval); $revenue = $cache->call(array($model, 'getRevenueChartData'), $state->stats_interval); $total = $cache->call(array($model, 'getSumChartData'), $orders); $sum = $cache->call(array($model, 'getSumChartData'), $revenue); $interval = $model->getStatIntervalValues($state->stats_interval); $view = $this->getView($this->get('suffix'), 'html'); $view->assign('orders', $orders); $view->assign('revenue', $revenue); $view->assign('total', $total); $view->assign('sum', $sum); $view->assign('interval', $interval); parent::display($cachable, $urlparams); }
/** * @return void */ function edit() { $redirect = "index.php?option=com_tienda&view=addresses"; $redirect = JRoute::_($redirect, false); $user = JFactory::getUser(); $model = $this->getModel($this->get('suffix')); $row = $model->getTable(); $row->load($model->getId()); // if id is present then user is editing, check if user can edit this item if (!empty($row->address_id) && $row->user_id != JFactory::getUser()->id) { $this->message = JText::_('COM_TIENDA_CANNOT_EDIT_ADDRESS_NOTICE'); $this->messagetype = 'notice'; $this->setRedirect($redirect, $this->message, $this->messagetype); return; } // else creating new item JRequest::setVar('hidemainmenu', '1'); JRequest::setVar('view', $this->get('suffix')); JRequest::setVar('layout', 'form'); $view = $this->getView('addresses', 'html'); $view->assign('form_inner', $this->getInnerAddressForm($row->address_id)); parent::display(); }
function setrates() { $this->set('suffix', 'taxrates'); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); foreach (@$state as $key => $value) { $model->setState($key, $value); } $row = JTable::getInstance('TaxClasses', 'TiendaTable'); $row->load($model->getId()); $model->setState('filter_taxclassid', $model->getId()); $view = $this->getView('taxrates', 'html'); $view->set('_controller', 'taxclasses'); $view->set('_view', 'taxclasses'); $view->set('_action', "index.php?option=com_tienda&controller=taxclasses&task=setrates&id={$model->getId()}&tmpl=component"); $view->setModel($model, true); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('default'); $view->setTask(true); $view->display(); }
/** * Overrides the delete method, to include the custom models and tables. */ public function delete() { $this->includeCustomModel('ShippingRates'); $this->includeCustomTables(); parent::delete(); }
/** * constructor */ function __construct() { parent::__construct(); $this->set('suffix', 'productissues'); }
function configzones() { $this->set('suffix', 'zonerelations'); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($this->get('suffix')); $ns = $this->getNamespace(); $state['filter_typeid'] = $app->getUserStateFromRequest($ns . 'typeid', 'filter_typeid', '', ''); $geozoneid = JRequest::getVar('geozoneid'); $state['filter_geozoneid'] = $geozoneid; foreach (@$state as $key => $value) { $model->setState($key, $value); } $id = JRequest::getVar('id', JRequest::getVar('id', '0', 'post', 'int'), 'get', 'int'); $row = $model->getTable('zonerelations'); $row->load($id); $view = $this->getView('zonerelations', 'html'); $view->set('_controller', 'zonerelations'); $view->set('_view', 'zonerelations'); $view->set('_action', "index.php?option=com_tienda&controller=zonerelations&task=configzones&tmpl=component&geozoneid={$geozoneid}"); $view->setModel($model, true); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('default'); $view->setTask(true); $view->display(); }
public function advanced($cachable = false, $urlparams = false) { JRequest::setVar('layout', 'advanced'); parent::display($cachable, $urlparams); }
/** * * @return void */ function search() { JRequest::setVar('view', $this->get('suffix')); JRequest::setVar('layout', 'search'); JRequest::setVar('search', true); parent::display(); }
/** * Method to assign payment/shipping methods to the geozones */ function selectplugins() { $type = JRequest::getVar('type'); Tienda::load("TiendaHelperPlugin", 'helpers.plugin'); $suffix = TiendaHelperPlugin::getSuffix($type); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($suffix); $ns = $app->getName() . '::' . 'com.tienda.model.' . $model->getTable()->get('_suffix'); $id = JRequest::getVar('id', JRequest::getVar('id', '0', 'post', 'int'), 'get', 'int'); $row = $model->getTable('geozones'); $row->load($id); $state['filter_enabled'] = '1'; $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', ''); $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.name', 'cmd'); foreach (@$state as $key => $value) { $model->setState($key, $value); } $view = $this->getView('geozones', 'html'); $view->set('_controller', 'geozones'); $view->set('_view', 'geozones'); $view->set('leftMenu', false); $view->set('_action', "index.php?option=com_tienda&controller=geozones&task=selectplugins&type={$type}&tmpl=component&id=" . $model->getId()); $view->setModel($model, true); $items = $model->getList(); foreach ($items as $item) { $params = new DSCParameter($item->params); $item->geozones = explode(',', $params->get('geozones')); } $view->assign('suffix', $suffix); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('selectplugins'); $view->setTask(true); $view->display(); }
/** * (non-PHPdoc) * * @see tienda/site/TiendaController#view() */ function display($cachable = false, $urlparams = false) { $user = $this->user; JRequest::setVar('view', $this->get('suffix')); //check if we have one page checkout if ($this->onepage_checkout) { if (!$user->id) { $session = JFactory::getSession(); $session->set('old_sessionid', $session->getId()); } // Display the onepage checkout view $opc_layout = $this->defines->get('one_page_checkout_layout', 'onepage-opc'); JRequest::setVar('layout', $opc_layout); $view = $this->getView($this->get('suffix'), 'html'); $order = $this->_order; $order = $this->populateOrder(); //get order summarry $html = $this->getOrderSummary(); $view->assign('orderSummary', $html); $view->assign('order', $order); $view->setTask(true); $view->assign('user', $user); if (!$user->id) { $view->form_user_register = $this->getAdditionalInfoUser(); } //get addresses JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('addresses', 'TiendaModel'); $model->setState("filter_userid", $this->user->id); $model->setState("filter_deleted", 0); $addresses = $model->getList(); // Checking whether shipping is required $showShipping = false; $cartsModel = $this->getModel('carts'); if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) { $showShipping = true; } $billingAddress = $order->getBillingAddress(); $billing_address_form = $this->getAddressForm($this->billing_input_prefix, !$user->id); $view->assign('billing_address_form', $billing_address_form); $view->assign('showShipping', $showShipping); $view->assign('billing_address', $billingAddress); if ($showShipping) { $shippingAddress = $order->getShippingAddress(); $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, !$user->id, true); $view->assign('shipping_address', $shippingAddress); $view->assign('shipping_address_form', $shipping_address_form); } Tienda::load('TiendaHelperPlugin', 'helpers.plugin'); $dispatcher = JDispatcher::getInstance(); if ($showShipping) { $rates = $this->getShippingRates(); $default_rate = array(); if (count($rates) == 1) { $default_rate = $rates[0]; } $shipping_layout = "shipping_yes"; if (empty($shippingAddress)) { $shipping_layout = "shipping_calculate"; } $shipping_method_form = $this->getShippingHtml($shipping_layout); $view->assign('showShipping', $showShipping); $view->assign('shipping_method_form', $shipping_method_form); $view->assign('rates', $rates); } $view->assign('payment_options_html', $this->getPaymentOptionsHtml()); $view->assign('order', $order); // are there any enabled coupons? $coupons_present = false; $model = JModel::getInstance('Coupons', 'TiendaModel'); $model->setState('filter_enabled', '1'); if ($coupons = $model->getList()) { $coupons_present = true; } $view->assign('coupons_present', $coupons_present); // assign userinfo for credits $userinfo = JTable::getInstance('UserInfo', 'TiendaTable'); $userinfo->load(array('user_id' => $this->user->id)); $userinfo->credits_total = (double) $userinfo->credits_total; $view->assign('userinfo', $userinfo); $view->assign('addresses', $addresses); $dispatcher = JDispatcher::getInstance(); ob_start(); $dispatcher->trigger('onBeforeDisplaySelectPayment', array($order)); $view->assign('onBeforeDisplaySelectPayment', ob_get_contents()); ob_end_clean(); ob_start(); $dispatcher->trigger('onAfterDisplaySelectPayment', array($order)); $view->assign('onAfterDisplaySelectPayment', ob_get_contents()); ob_end_clean(); } else { $guest_var = JRequest::getInt('guest', '0'); $guest = false; if ($guest_var == '1') { $guest = true; } $register_var = JRequest::getInt('register', '0'); $form_register = ''; $register = false; if ($register_var == '1') { $register = true; $form_register = $this->getRegisterForm(); } // determine layout based on login status // Login / Register / Checkout as a guest if (empty($user->id) && !($guest || $register)) { // Display a form for selecting either to register or to login JRequest::setVar('layout', 'form'); Tienda::load("TiendaHelperRoute", 'helpers.route'); $helper = new TiendaHelperRoute(); $view = $this->getView('checkout', 'html'); $checkout_itemid = $helper->findItemid(array('view' => 'checkout')); if (empty($checkout_itemid)) { $checkout_itemid = JRequest::getInt('Itemid'); } $view->assign('checkout_itemid', $checkout_itemid); parent::display(); return; } if ($guest && $this->defines->get('guest_checkout_enabled') || $register) { // Checkout as a Guest $order = $this->_order; $order = $this->populateOrder(true); // now that the order object is set, get the orderSummary html $html = $this->getOrderSummary(); // Get the current step $progress = $this->getProgress(); // get address forms $billing_address_form = $this->getAddressForm($this->billing_input_prefix, true); $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, true, true); // get all the enabled shipping plugins Tienda::load('TiendaHelperPlugin', 'helpers.plugin'); $plugins = TiendaHelperPlugin::getPluginsWithEvent('onGetShippingPlugins'); $dispatcher = JDispatcher::getInstance(); $rates = array(); if ($plugins) { foreach ($plugins as $plugin) { $results = $dispatcher->trigger("onGetShippingRates", array($plugin->element, $order)); foreach ($results as $result) { if (is_array($result)) { foreach ($result as $r) { $rates[] = $r; } } } // endforeach results } // endforeach plugins } // endif plugins // now display the entire checkout page $view = $this->getView('checkout', 'html'); $view->set('hidemenu', false); $view->assign('order', $order); $view->assign('register', $register); $view->assign('form_register', $form_register); $view->assign('billing_address_form', $billing_address_form); $view->assign('shipping_address_form', $shipping_address_form); $view->assign('orderSummary', $html); $view->assign('progress', $progress); //$view->assign( 'default_billing_address', $default_billing_address ); //$view->assign( 'default_shipping_address', $default_shipping_address ); $view->assign('rates', $rates); // Checking whether shipping is required $showShipping = false; $shipping_layout = "shipping_no"; $cartsModel = $this->getModel('carts'); if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) { $showShipping = true; } if ($showShipping) { $shipping_layout = "shipping_yes"; if (empty($shippingAddress)) { $shipping_layout = "shipping_calculate"; } } $shipping_method_form = $this->getShippingHtml($shipping_layout); $view->assign('showShipping', $showShipping); $view->assign('shipping_method_form', $shipping_method_form); JRequest::setVar('layout', 'guest'); } else { // Already Logged in, a traditional checkout $order = $this->_order; $order = $this->populateOrder(false); // now that the order object is set, get the orderSummary html $html = $this->getOrderSummary(); // Get the current step $progress = $this->getProgress(); $user_id = $this->user->id; $addresses = array(); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('addresses', 'TiendaModel'); if (!empty($user_id)) { $model->setState("filter_userid", $user_id); $model->setState("filter_deleted", 0); $addresses = $model->getList(); } $billingAddress = $order->getBillingAddress(); $shippingAddress = $order->getShippingAddress(); // get address forms $billing_address_form = $this->getAddressForm($this->billing_input_prefix); $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, false, true); // get the default shipping and billing addresses, if possible $default_billing_address = $this->getAddressHtml(@$billingAddress->address_id); $default_shipping_address = $this->getAddressHtml(@$shippingAddress->address_id); // now display the entire checkout page $view = $this->getView('checkout', 'html'); $view->set('hidemenu', false); $view->assign('order', $order); $view->assign('addresses', $addresses); $view->assign('billing_address', $billingAddress); $view->assign('shipping_address', $shippingAddress); $view->assign('billing_address_form', $billing_address_form); $view->assign('shipping_address_form', $shipping_address_form); $view->assign('orderSummary', $html); $view->assign('progress', $progress); $view->assign('default_billing_address', $default_billing_address); $view->assign('default_shipping_address', $default_shipping_address); // Check whether shipping is required $showShipping = false; $shipping_layout = "shipping_no"; $cartsModel = $this->getModel('carts'); if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) { $showShipping = true; } if ($showShipping) { $shipping_layout = "shipping_yes"; if (empty($shippingAddress)) { $shipping_layout = "shipping_calculate"; } } $shipping_method_form = $this->getShippingHtml($shipping_layout); $view->assign('showShipping', $showShipping); $view->assign('shipping_method_form', $shipping_method_form); JRequest::setVar('layout', 'default'); } $dispatcher = JDispatcher::getInstance(); ob_start(); $dispatcher->trigger('onBeforeDisplaySelectShipping', array($order)); $view->assign('onBeforeDisplaySelectShipping', ob_get_contents()); ob_end_clean(); ob_start(); $dispatcher->trigger('onAfterDisplaySelectShipping', array($order)); $view->assign('onAfterDisplaySelectShipping', ob_get_contents()); ob_end_clean(); } $view->setTask(true); $view->assign('default_country', $this->default_country); $view->assign('default_country_id', $this->default_country_id); parent::display(); return; }