public function setMedia() { parent::setMedia(); if ($this->step == 2) { $this->addJS(_THEME_JS_DIR_ . 'order-carrier.js'); } }
protected function _assignPayment() { global $orderTotal; $invoice_address = new Address((int) self::$cart->id_address_invoice); if ($invoice_address->id_country != 110) { include_once _PS_MODULE_DIR_ . 'paypal/paypal.php'; include_once _PS_MODULE_DIR_ . 'paypal/payment/paypalpayment.php'; include_once _PS_MODULE_DIR_ . 'paypal/payment/submit.php'; //GetPaypal stuff unset(self::$cookie->paypal_token); /*if (self::$cart->id_currency != $ppPayment->getCurrency((int) self::$cart->id_currency)->id) { self::$cart->id_currency = (int) ($ppPayment->getCurrency((int) self::$cart->id_currency)->id); self::$cookie->id_currency = (int) (self::$cart->id_currency); self::$cart->update(); Tools::redirect('modules/' . $ppPayment->name . '/payment/submit.php'); }*/ $curr_sel_currency = CurrencyCore::getCurrency(self::$cart->id_currency); self::$smarty->assign(array('cust_currency' => self::$cart->id_currency, 'currency' => $curr_sel_currency, 'total' => self::$cart->getOrderTotal(true, Cart::BOTH), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/')); } // Redirect instead of displaying payment modules if any module are grefted on Hook::backBeforePayment('order.php?step=3'); /* We may need to display an order summary */ self::$smarty->assign(self::$cart->getSummaryDetails()); self::$smarty->assign(array('total_price' => Tools::ps_round((double) $orderTotal), 'taxes_enabled' => (int) Configuration::get('PS_TAX'))); self::$cookie->checkedTOS = '1'; parent::_assignPayment(); }
/** * Payment step */ protected function _assignPayment() { global $orderTotal; // Redirect instead of displaying payment modules if any module are grefted on Hook::exec('displayBeforePayment', array('module' => 'order.php?step=3')); /* We may need to display an order summary */ $this->context->smarty->assign($this->context->cart->getSummaryDetails()); $this->context->smarty->assign(array('total_price' => (double) $orderTotal, 'taxes_enabled' => (int) Configuration::get('PS_TAX'))); $this->context->cart->checkedTOS = '1'; parent::_assignPayment(); }
protected function _assignCarrier() { if (!$this->isLogged) { $carriers = $this->context->cart->simulateCarriersOutput(); $oldMessage = Message::getMessageByCartId((int) $this->context->cart->id); $this->context->smarty->assign(array('HOOK_EXTRACARRIER' => null, 'HOOK_EXTRACARRIER_ADDR' => null, 'oldMessage' => isset($oldMessage['message']) ? $oldMessage['message'] : '', 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers, 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'delivery_option' => $this->context->cart->getDeliveryOption(null, true))))); } else { parent::_assignCarrier(); } }
protected function _assignCarrier() { if (!$this->isLogged) { $carriers = Carrier::getCarriersForOrder(Country::getIdZone((int) Configuration::get('PS_COUNTRY_DEFAULT'))); self::$smarty->assign(array('checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'default_carrier' => (int) Configuration::get('PS_CARRIER_DEFAULT'), 'HOOK_EXTRACARRIER' => NULL, 'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)))); } else { parent::_assignCarrier(); } }
protected function _assignPayment() { if (Configuration::get('PS_EU_PAYMENT_API')) { return ParentOrderController::_assignPayment(); } else { return parent::_assignPayment(); } }
public function initContent() { $internal_referrer = isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Dispatcher::getInstance()->createUrl('order-opc', $this->context->cookie->id_lang)); $upsell = @Module::getInstanceByName('upsell'); if ($upsell && $upsell->active && !(Tools::getValue('skip_offers') == 1 || $internal_referrer)) { ParentOrderController::initContent(); // We need this to display the page properly (parent of overriden controller) $upsell->getUpsells(); $this->template = $upsell->setTemplate('upsell-products.tpl'); } else { if (!$this->isOpcModuleActive()) { return parent::initContent(); } $this->origInitContent(); $this->_assignSummaryInformations(); $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isLogged' => $this->isLogged, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (Tools::getIsset('isPaymentStep') && Tools::getValue('isPaymentStep')), 'genders' => Gender::getGenders())); $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); if ($this->isLogged) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } if ($this->context->cart->id_address_delivery > 0) { $def_address = new Address($this->context->cart->id_address_delivery); $def_country = $def_address->id_country; $def_state = $def_address->id_state; } else { $def_country = 0; $def_state = 0; } if ($this->context->cart->id_address_invoice > 0) { $def_address_invoice = new Address($this->context->cart->id_address_invoice); $def_country_invoice = $def_address_invoice->id_country; $def_state_invoice = $def_address_invoice->id_state; } else { $def_country_invoice = 0; $def_state_invoice = 0; } if ($this->context->cart->id_address_delivery > 0 && $this->context->cart->id_address_invoice > 0 && $this->context->cart->id_address_delivery != $this->context->cart->id_address_invoice) { $def_different_billing = 1; } else { $def_different_billing = 0; } $this->context->smarty->assign('def_different_billing', $def_different_billing); $this->context->smarty->assign('def_country', $def_country); $this->context->smarty->assign('def_state', $def_state); $this->context->smarty->assign('def_country_invoice', $def_country_invoice); $this->context->smarty->assign('def_state_invoice', $def_state_invoice); if ($this->isLogged) { $this->_assignAddress(); } // ADDRESS $this->_assignCarrier(); $this->_assignPayment(); Tools::safePostVars(); if (!$this->context->cart->isMultiAddressDelivery()) { $this->context->cart->setNoMultishipping(); } // As the cart is no multishipping, set each delivery address lines with the main delivery address $summary = $this->context->cart->getSummaryDetails(null, true); // to force refresh on product.id_address_delivery $this->_assignSummaryInformations(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active)); $this->context->smarty->assign('opc_templates_path', $this->opc_templates_path); $this->context->smarty->assign('twoStepCheckout', false); // TODO: hardcoded value! $online_country = new Country($this->opc_config['online_country_id']); if ($online_country->active) { $this->context->smarty->assign('onlineCountryActive', true); } if (Tools::isSubmit('cart-only')) { $this->context->smarty->assign('onlyCartSummary', '1'); $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE')); $this->setTemplate('shopping-cart.tpl'); } else { $this->setTemplate('order-opc.tpl'); } } }
public function init() { ParentOrderController::init(); if ($this->nbProducts) { $this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart()); } $this->context->smarty->assign('is_multi_address_delivery', $this->context->cart->isMultiAddressDelivery() || (int) Tools::getValue('multi-shipping') == 1); $this->context->smarty->assign('open_multishipping_fancybox', (int) Tools::getValue('multi-shipping') == 1); if ($this->context->cart->nbProducts()) { if (Tools::isSubmit('ajax')) { if (Tools::isSubmit('method')) { switch (Tools::getValue('method')) { case 'updateMessage': if (Tools::isSubmit('message')) { $txt_message = urldecode(Tools::getValue('message')); $this->_updateMessage($txt_message); if (count($this->errors)) { $this->ajaxDie('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}'); } $this->ajaxDie(true); } break; case 'updateCarrierAndGetPayments': if ((Tools::isSubmit('delivery_option') || Tools::isSubmit('id_carrier')) && Tools::isSubmit('recyclable') && Tools::isSubmit('gift') && Tools::isSubmit('gift_message')) { $this->_assignWrappingAndTOS(); if ($this->_processCarrier()) { $carriers = $this->context->cart->simulateCarriersOutput(); $return = array_merge(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'carrier_data' => $this->_getCarrierList(), 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers))), $this->getFormatedSummaryDetail()); Cart::addExtraCarriers($return); $this->ajaxDie(Tools::jsonEncode($return)); } else { $this->errors[] = Tools::displayError('An error occurred while updating the cart.'); } if (count($this->errors)) { $this->ajaxDie('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}'); } exit; } break; case 'updateTOSStatusAndGetPayments': if (Tools::isSubmit('checked')) { $this->context->cookie->checkedTOS = (int) Tools::getValue('checked'); $this->ajaxDie(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods()))); } break; case 'getCarrierList': $this->ajaxDie(Tools::jsonEncode($this->_getCarrierList())); break; case 'editCustomer': if (!$this->isLogged || !$this->context->customer->is_guest) { exit; } if (Validate::isEmail($email = Tools::getValue('email')) && !empty($email)) { if (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered.', false); } } if (Tools::getValue('years')) { $this->context->customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days'); } $_POST['lastname'] = $_POST['customer_lastname']; $_POST['firstname'] = $_POST['customer_firstname']; if (isset($_POST['customer_fax'])) { $_POST['fax'] = $_POST['customer_fax']; } if (isset($_POST['customer_details_website'])) { $_POST['details_website'] = $_POST['customer_details_website']; } $this->errors = array_merge($this->errors, $this->context->customer->validateController()); $this->context->customer->newsletter = (int) Tools::isSubmit('newsletter'); $this->context->customer->optin = (int) Tools::isSubmit('optin'); $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) $this->context->customer->id, 'token' => Tools::getToken(false)); if (!count($this->errors)) { $return['isSaved'] = (bool) $this->context->customer->update(); } else { $return['isSaved'] = false; } $this->ajaxDie(Tools::jsonEncode($return)); break; case 'getAddressBlockAndCarriersAndPayments': if ($this->context->customer->isLogged()) { // check if customer have addresses if (!Customer::getAddressesTotalById($this->context->customer->id)) { $this->ajaxDie(Tools::jsonEncode(array('no_address' => 1))); } if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) { include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php'; $block_user_info = new BlockUserInfo(); } $this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart()); $this->_processAddressFormat(); $this->_assignAddress(); if (!($formated_address_fields_values_list = $this->context->smarty->getTemplateVars('formatedAddressFieldsValuesList'))) { $formated_address_fields_values_list = array(); } // Wrapping fees $wrapping_fees = $this->context->cart->getGiftWrappingPrice(false); $wrapping_fees_tax_inc = $this->context->cart->getGiftWrappingPrice(); $return = array_merge(array('order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($block_user_info) ? $block_user_info->hookDisplayTop(array()) : '', 'formatedAddressFieldsValuesList' => $formated_address_fields_values_list, 'carrier_data' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) $this->context->cookie->id_currency)))), $this->getFormatedSummaryDetail()); $this->ajaxDie(Tools::jsonEncode($return)); } die(Tools::displayError()); break; case 'makeFreeOrder': /* Bypass payment step if total is 0 */ if (($id_order = $this->_checkFreeOrder()) && $id_order) { $order = new Order((int) $id_order); $email = $this->context->customer->email; if ($this->context->customer->is_guest) { $this->context->customer->logout(); } // If guest we clear the cookie for security reason $this->ajaxDie('freeorder:' . $order->reference . ':' . $email); } exit; break; case 'updateAddressesSelected': if ($this->context->customer->isLogged(true)) { $address_delivery = new Address((int) Tools::getValue('id_address_delivery')); $this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart()); $address_invoice = (int) Tools::getValue('id_address_delivery') == (int) Tools::getValue('id_address_invoice') ? $address_delivery : new Address((int) Tools::getValue('id_address_invoice')); if ($address_delivery->id_customer != $this->context->customer->id || $address_invoice->id_customer != $this->context->customer->id) { $this->errors[] = Tools::displayError('This address is not yours.'); } elseif (!Address::isCountryActiveById((int) Tools::getValue('id_address_delivery'))) { $this->errors[] = Tools::displayError('This address is not in a valid area.'); } elseif (!Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) { $this->errors[] = Tools::displayError('This address is invalid.'); } else { $this->context->cart->id_address_delivery = (int) Tools::getValue('id_address_delivery'); $this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int) Tools::getValue('id_address_invoice'); if (!$this->context->cart->update()) { $this->errors[] = Tools::displayError('An error occurred while updating your cart.'); } $infos = Address::getCountryAndState((int) $this->context->cart->id_address_delivery); if (isset($infos['id_country']) && $infos['id_country']) { $country = new Country((int) $infos['id_country']); $this->context->country = $country; } // Address has changed, so we check if the cart rules still apply $cart_rules = $this->context->cart->getCartRules(); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); if ((int) Tools::getValue('allow_refresh')) { // If the cart rules has changed, we need to refresh the whole cart $cart_rules2 = $this->context->cart->getCartRules(); if (count($cart_rules2) != count($cart_rules)) { $this->ajax_refresh = true; } else { $rule_list = array(); foreach ($cart_rules2 as $rule) { $rule_list[] = $rule['id_cart_rule']; } foreach ($cart_rules as $rule) { if (!in_array($rule['id_cart_rule'], $rule_list)) { $this->ajax_refresh = true; break; } } } } if (!$this->context->cart->isMultiAddressDelivery()) { $this->context->cart->setNoMultishipping(); } // As the cart is no multishipping, set each delivery address lines with the main delivery address if (!count($this->errors)) { $result = $this->_getCarrierList(); // Wrapping fees $wrapping_fees = $this->context->cart->getGiftWrappingPrice(false); $wrapping_fees_tax_inc = $this->context->cart->getGiftWrappingPrice(); $result = array_merge($result, array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) $this->context->cookie->id_currency))), 'carrier_data' => $this->_getCarrierList(), 'refresh' => (bool) $this->ajax_refresh), $this->getFormatedSummaryDetail()); $this->ajaxDie(Tools::jsonEncode($result)); } } if (count($this->errors)) { $this->ajaxDie(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors))); } } die(Tools::displayError()); break; case 'multishipping': $this->_assignSummaryInformations(); $this->context->smarty->assign('product_list', $this->context->cart->getProducts()); if ($this->context->customer->id) { $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id)); } else { $this->context->smarty->assign('address_list', array()); } $this->setTemplate(_PS_THEME_DIR_ . 'order-address-multishipping-products.tpl'); $this->display(); $this->ajaxDie(); break; case 'cartReload': $this->_assignSummaryInformations(); if ($this->context->customer->id) { $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id)); } else { $this->context->smarty->assign('address_list', array()); } $this->context->smarty->assign('opc', true); $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl'); $this->display(); $this->ajaxDie(); break; case 'noMultiAddressDelivery': $this->context->cart->setNoMultishipping(); $this->ajaxDie(); break; default: throw new PrestaShopException('Unknown method "' . Tools::getValue('method') . '"'); } } else { throw new PrestaShopException('Method is not defined'); } } } elseif (Tools::isSubmit('ajax')) { $this->errors[] = Tools::displayError('There is no product in your cart.'); $this->ajaxDie('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}'); } }
public function initContent() { ParentOrderController::initContent(); if (Tools::isSubmit('ajax') && Tools::getValue('method') == 'updateExtraCarrier') { // Change virtualy the currents delivery options $delivery_option = $this->context->cart->getDeliveryOption(); $delivery_option[(int) Tools::getValue('id_address')] = Tools::getValue('id_delivery_option'); $this->context->cart->setDeliveryOption($delivery_option); $this->context->cart->save(); $return = array('content' => Hook::exec('displayCarrierList', array('address' => new Address((int) Tools::getValue('id_address'))))); die(Tools::jsonEncode($return)); } if ($this->nbProducts) { $this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart()); } // 4 steps to the order switch ((int) $this->step) { case -1: $this->context->smarty->assign('empty', 1); if ($this->_legal && ($tpl = $this->_legal->getThemeOverride('shopping-cart'))) { $this->setTemplate($tpl); } else { $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl'); } break; case 1: $this->_assignAddress(); $this->processAddressFormat(); if (Tools::getValue('multi-shipping') == 1) { $this->_assignSummaryInformations(); $this->context->smarty->assign('product_list', $this->context->cart->getProducts()); $this->setTemplate(_PS_THEME_DIR_ . 'order-address-multishipping.tpl'); } else { $this->setTemplate(_PS_THEME_DIR_ . 'order-address.tpl'); } break; case 2: if (Tools::isSubmit('processAddress')) { $this->processAddress(); } $this->autoStep(); $this->_assignCarrier(); if ($this->_legal && ($tpl = $this->_legal->getThemeOverride('order-carrier'))) { $this->setTemplate($tpl); } else { $this->setTemplate(_PS_THEME_DIR_ . 'order-carrier.tpl'); } break; case 3: // Check that the conditions (so active) were accepted by the customer // Only do it when EU Payment Module API is not active: When EU Payment is active TOS are checked // on last page of order process... well, when Javascript is available :) if (!Configuration::get('PS_EU_PAYMENT_API') || Tools::getValue('cgv_checkbox_shown')) { $cgv = Tools::getValue('cgv') || $this->context->cookie->check_cgv; if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv) || $cgv == false)) { Tools::redirect('index.php?controller=order&step=2'); } Context::getContext()->cookie->check_cgv = true; } // Check the delivery option is set if (!$this->context->cart->isVirtualCart()) { if (!Tools::getValue('delivery_option') && !Tools::getValue('id_carrier') && !$this->context->cart->delivery_option && !$this->context->cart->id_carrier) { Tools::redirect('index.php?controller=order&step=2'); } elseif (!Tools::getValue('id_carrier') && !$this->context->cart->id_carrier) { $deliveries_options = Tools::getValue('delivery_option'); if (!$deliveries_options) { $deliveries_options = $this->context->cart->delivery_option; } foreach ($deliveries_options as $delivery_option) { if (empty($delivery_option)) { Tools::redirect('index.php?controller=order&step=2'); } } } } $this->autoStep(); // Bypass payment step if total is 0 if (($id_order = $this->_checkFreeOrder()) && $id_order) { if ($this->context->customer->is_guest) { $order = new Order((int) $id_order); $email = $this->context->customer->email; $this->context->customer->mylogout(); // If guest we clear the cookie for security reason Tools::redirect('index.php?controller=guest-tracking&id_order=' . urlencode($order->reference) . '&email=' . urlencode($email)); } else { Tools::redirect('index.php?controller=history'); } } $this->_assignPayment(); // assign some informations to display cart $this->_assignSummaryInformations(); if ($this->_legal && ($tpl = $this->_legal->getThemeOverride('order-payment'))) { $this->setTemplate($tpl); } else { $this->setTemplate(_PS_THEME_DIR_ . 'order-payment.tpl'); } break; default: $this->_assignSummaryInformations(); if ($this->_legal && ($tpl = $this->_legal->getThemeOverride('shopping-cart'))) { $this->setTemplate($tpl); } else { $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl'); } break; } $this->context->smarty->assign(array('currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank)); }
public function initContent() { // Upsell integration $internal_referrer = isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Dispatcher::getInstance()->createUrl('order-opc', $this->context->cookie->id_lang)); $upsell = @Module::getInstanceByName('upsell'); if ($upsell && $upsell->active && !(Tools::getValue('skip_offers') == 1 || $internal_referrer)) { ParentOrderController::initContent(); // We need this to display the page properly (parent of overriden controller) $upsell->getUpsells(); $this->template = $upsell->setTemplate('upsell-products.tpl'); } else { if (!$this->isOpcModuleActive()) { return parent::initContent(); } // parent::initContent(); - toto by volalo celu metodu aj s volanim sablony z default themy $this->origInitContent(); // SHOPPING CART $this->_assignSummaryInformations(); // WRAPPING AND TOS $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } // If a rule offer free-shipping, force hidding shipping prices $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isLogged' => $this->isLogged, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (Tools::getIsset('isPaymentStep') && Tools::getValue('isPaymentStep')), 'genders' => Gender::getGenders())); /* Call a hook to display more information on form */ $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); /* Load guest informations */ //if ($this->isLogged && $this->context->cookie->is_guest) // opckt changed. if ($this->isLogged) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } // OPCKT default address update - in case customer is not yet logged-in and address is not // yet entered and refresh happens if ($this->context->cart->id_address_delivery > 0) { $def_address = new Address($this->context->cart->id_address_delivery); $def_country = $def_address->id_country; $def_state = $def_address->id_state; } else { $def_country = 0; $def_state = 0; } if ($this->context->cart->id_address_invoice > 0) { $def_address_invoice = new Address($this->context->cart->id_address_invoice); $def_country_invoice = $def_address_invoice->id_country; $def_state_invoice = $def_address_invoice->id_state; } else { $def_country_invoice = 0; $def_state_invoice = 0; } if ($this->context->cart->id_address_delivery > 0 && $this->context->cart->id_address_invoice > 0 && $this->context->cart->id_address_delivery != $this->context->cart->id_address_invoice) { $def_different_billing = 1; } else { $def_different_billing = 0; } $this->context->smarty->assign('def_different_billing', $def_different_billing); $this->context->smarty->assign('def_country', $def_country); $this->context->smarty->assign('def_state', $def_state); $this->context->smarty->assign('def_country_invoice', $def_country_invoice); $this->context->smarty->assign('def_state_invoice', $def_state_invoice); if ($this->isLogged) { $this->_assignAddress(); } // ADDRESS // CARRIER $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); Tools::safePostVars(); if (!$this->context->cart->isMultiAddressDelivery()) { $this->context->cart->setNoMultishipping(); } // As the cart is no multishipping, set each delivery address lines with the main delivery address // cart-summary $summary = $this->context->cart->getSummaryDetails(null, true); // to force refresh on product.id_address_delivery $this->_assignSummaryInformations(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active)); //$this->_processAddressFormat(); - v OPC module to nepotrebujeme, to je len format // "offline" needitovatelnej adresy //$this->setTemplate(_PS_THEME_DIR_.'order-opc.tpl'); $this->context->smarty->assign('opc_templates_path', $this->opc_templates_path); $this->context->smarty->assign('twoStepCheckout', false); // TODO: hardcoded value! //$this->context->smarty->assign('paypal_express_checkout_on', isset($this->context->cookie->express_checkout)); $online_country = new Country($this->opc_config['online_country_id']); if ($online_country->active) { $this->context->smarty->assign('onlineCountryActive', true); } if (Tools::isSubmit('cart-only')) { $this->context->smarty->assign('onlyCartSummary', '1'); $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE')); $this->setTemplate('shopping-cart.tpl'); } else { $this->setTemplate('order-opc.tpl'); } } }