示例#1
0
文件: checkout.php 项目: A-Bush/pprod
 function guest()
 {
     $app = JFactory::getApplication();
     $cart_model = $this->getModel('mycart');
     $view = $this->getView('checkout', 'html');
     $model = $this->getModel('checkout');
     $this->session->set('uaccount', 'guest', 'k2store');
     //check inventory
     $products = $cart_model->getDataNew();
     try {
         K2StoreInventory::validateQuantityRestrictions($products);
     } catch (Exception $e) {
         $app->redirect($link, $e->getMessage());
     }
     //set guest varibale to session as the array, if it does not exist
     if (!$this->session->has('guest', 'k2store')) {
         $this->session->set('guest', array(), 'k2store');
     }
     $guest = $this->session->get('guest', array(), 'k2store');
     $data = array();
     $selectableBase = new K2StoreSelectableBase();
     $view->assign('fieldsClass', $selectableBase);
     $address = JTable::getInstance('address', 'Table');
     if (empty($guest['billing']['zip']) && $this->session->has('billing_postcode', 'k2store')) {
         $guest['billing']['zip'] = $this->session->get('billing_postcode', '', 'k2store');
     }
     if (empty($guest['billing']['country_id']) && $this->session->has('billing_country_id', 'k2store')) {
         $guest['billing']['country_id'] = $this->session->get('billing_country_id', '', 'k2store');
     }
     if (empty($guest['billing']['zone_id']) && $this->session->has('billing_zone_id', 'k2store')) {
         $guest['billing']['zone_id'] = $this->session->get('billing_zone_id', '', 'k2store');
     }
     //bind the guest data to address table if it exists in the session
     if (isset($guest['billing']) && count($guest['billing'])) {
         $address->bind($guest['billing']);
     }
     $fields = $selectableBase->getFields('guest', $address, 'address');
     $view->assign('fields', $fields);
     $view->assign('address', $address);
     //get layout settings
     $storeProfile = K2StoreHelperCart::getStoreAddress();
     $view->assign('storeProfile', K2StoreHelperCart::getStoreAddress());
     $showShipping = false;
     if ($this->params->get('show_shipping_address', 0)) {
         $showShipping = true;
     }
     if ($isShippingEnabled = $cart_model->getShippingIsEnabled()) {
         $showShipping = true;
     }
     $view->assign('showShipping', $showShipping);
     $data['shipping_required'] = $showShipping;
     if (isset($guest['shipping_address'])) {
         $data['shipping_address'] = $guest['shipping_address'];
     } else {
         $data['shipping_address'] = true;
     }
     $view->assign('data', $data);
     $view->setLayout('checkout_guest');
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     echo $html;
     $app->close();
 }