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); }
/** * (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); }
/** * (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(); }
/** * 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); }
function display($cachable = false, $urlparams = false) { $post = JRequest::get('post'); $step = JRequest::getVar('nextstep', 'step1'); if (empty($step)) { $step = 'step1'; } DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $elementUserModel = DSCModel::getInstance('ElementUser', 'TiendaModel'); $session = JFactory::getSession(); $view = $this->getView('pos', 'html'); $view->assign('session', $session); $view->assign('step', $step); $view->assign('validation_url', $this->validation_url); $view->setModel($elementUserModel); $view->setTask(true); $method_name = 'do' . $step; if (method_exists($this, $method_name)) { $this->{$method_name}($post); } parent::display($cachable, $urlparams); }
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(); }
/** * * @return void */ function search() { JRequest::setVar('view', $this->get('suffix')); JRequest::setVar('layout', 'search'); JRequest::setVar('search', true); parent::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; }
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); $model = $this->getModel($this->get('suffix')); $this->_setModelState(); if (!Tienda::getInstance()->get('display_out_of_stock')) { $model->setState('filter_quantity_from', '1'); } parent::display(); // TODO In the future, make "Redirect to Advanced Search from Search Module?" an option in Tienda Config // $query = array(); // // now that we have it, let's clean the post and redirect to the advanced search page // // use the itemid from the request, so the user stays on the same menu item as they previously were on // // $query['Itemid'] = JRequest::getInt('Itemid'); // if (empty($query['Itemid'])) // { // // TODO Use Tienda Router to get the item_id for a tienda shop link // //$item_id = 0; // //$query['Itemid'] = $item_id; // } // // $badchars = array('#','>','<','\\'); // $filter = trim(str_replace($badchars, '', JRequest::getString('filter', null, 'post'))); // $query['filter'] = $filter; // // $query['view'] = 'search'; // // $uri = JURI::getInstance(); // $uri->setQuery($query); // $uri->setVar('option', 'com_tienda'); // // $this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query', 'fragment')), false)); }
/** * (non-PHPdoc) * @see TiendaController::display() */ function view($cachable = false, $urlparams = '') { $model = $this->getModel($this->get('suffix')); $items_model = $this->getModel('wishlistitems'); $products_model = $this->getModel('products'); Tienda::load("TiendaHelperRoute", 'helpers.route'); $router = TiendaHelperBase::getInstance('Route'); // clear unecessary session ids $items_model->clearSessionIds(); $user = JFactory::getUser(); $items_model->mergeUserItems($user->id); $this->_setModelState(); $wishlist_id = JRequest::getInt('id'); $item = $model->getItem($wishlist_id); $redirect = JRoute::_("index.php?option=com_tienda&view=wishlists&Itemid=" . $router->findItemid(array('view' => 'wishlists')), false); if ($item == null) { // this item does not exist $this->messagetype = 'error'; $this->message = JText::_('COM_TIENDA_WISHLIST_DOEST_EXIST'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } // TODO Is this a public or the user's wishlist? if no, fail. $items_model->setState('filter_wishlist', $wishlist_id); if ($items = $items_model->getList(true)) { } $checkout_itemid = $router->findItemid(array('view' => 'checkout')); if (empty($checkout_itemid)) { $checkout_itemid = JRequest::getInt('Itemid'); } if ($return = JRequest::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } } $redirect = $return ? $return : JRoute::_("index.php?option=com_tienda&view=products"); $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType()); $view->assign('return', $redirect); $view->assign('checkout_itemid', $checkout_itemid); $view->assign('row', $item); $view->assign('items', $items); $view->set('no_items', true); $view->set('hidemenu', true); $view->set('_doTask', true); $view->setModel($model, true); $view->setModel($items_model); $view->setModel($products_model); $view->setLayout('view'); JRequest::setVar('layout', 'view'); parent::display($cachable, $urlparams); }
/** * * Enter description here ... * @return unknown_type */ function editAddresses() { JRequest::setVar('layout', 'form_addresses'); parent::display(); }