public function run() { $this->init(); $this->preProcess(); if (Tools::getValue('ajax') == 'true') { if (Tools::getIsset('summary')) { $result = array(); if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { if (self::$cookie->id_customer) { $customer = new Customer((int) self::$cookie->id_customer); $groups = $customer->getGroups(); } else { $groups = array(1); } if ((int) self::$cart->id_address_delivery) { $deliveryAddress = new Address((int) self::$cart->id_address_delivery); $id_zone = Address::getZoneById((int) $deliveryAddress->id); } if (!isset($id_zone)) { $id_zone = (int) Country::getIdZone(isset($deliveryAddress) && (int) $deliveryAddress->id ? (int) $deliveryAddress->id_country : (int) _PS_COUNTRY_DEFAULT_); } $result['carriers'] = Carrier::getCarriersForOrder($id_zone, $groups); $result['checked'] = Carrier::getDefaultCarrierSelection($result['carriers'], (int) self::$cart->id_carrier); $result['HOOK_EXTRACARRIER'] = Module::hookExec('extraCarrier', array('address' => isset($deliveryAddress) && (int) $deliveryAddress->id ? $deliveryAddress : null)); } $result['summary'] = self::$cart->getSummaryDetails(); $result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id); $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']); die(Tools::jsonEncode($result)); } else { $this->includeCartModule(); } } else { $this->setMedia(); $this->displayHeader(); $this->process(); $this->displayContent(); $this->displayFooter(); } }
/** * Decides what the default carrier is and update the cart with it * * @param array $carriers * * @deprecated since 1.5.0 * * @return number the id of the default carrier */ protected function _setDefaultCarrierSelection($carriers) { $this->context->cart->id_carrier = Carrier::getDefaultCarrierSelection($carriers, (int) $this->context->cart->id_carrier); if ($this->context->cart->update()) { return $this->context->cart->id_carrier; } return 0; }
/** * Decides what the default carrier is and update the cart with it * * @param array $carriers * @return number the id of the default carrier */ protected function _setDefaultCarrierSelection($carriers) { self::$cart->id_carrier = Carrier::getDefaultCarrierSelection($carriers, (int) self::$cart->id_carrier); if (self::$cart->update()) { return self::$cart->id_carrier; } return 0; }