Beispiel #1
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::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')))));
         $this->ajaxDie(Tools::jsonEncode($return));
     }
     if ($this->nbProducts) {
         $this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart());
     }
     if (!Tools::getValue('multi-shipping')) {
         $this->context->cart->setNoMultishipping();
     }
     // 4 steps to the order
     switch ((int) $this->step) {
         case -1:
             $this->context->smarty->assign('empty', 1);
             $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->_assignPayment();
             // assign some informations to display cart
             $this->_assignSummaryInformations();
             $this->setTemplate(_PS_THEME_DIR_ . 'order-payment.tpl');
             break;
         default:
             $this->_assignSummaryInformations();
             $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl');
             break;
     }
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::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());
     }
     if (!Tools::getValue('multi-shipping')) {
         $this->context->cart->setNoMultishipping();
     }
     // 4 steps to the order
     switch ((int) $this->step) {
         case -1:
             $this->context->smarty->assign('empty', 1);
             $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();
             $this->setTemplate(_PS_THEME_DIR_ . 'order-carrier.tpl');
             break;
         case 3:
             // Check that the conditions (so active) were accepted by the customer
             $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();
             $this->setTemplate(_PS_THEME_DIR_ . 'order-payment.tpl');
             break;
         default:
             $this->_assignSummaryInformations();
             $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));
 }
Beispiel #3
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
     if (empty($this->context->cart->id_carrier)) {
         $checked = $this->context->cart->simulateCarrierSelectedOutput();
         $checked = (int) Cart::desintifier($checked);
         $this->context->cart->id_carrier = $checked;
         $this->context->cart->update();
         CartRule::autoRemoveFromCart($this->context);
         CartRule::autoAddToCart($this->context);
     }
     // 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, '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.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), '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) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     // ADDRESS
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $blocknewsletter = Module::getInstanceByName('blocknewsletter');
     $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active));
     $this->_processAddressFormat();
     $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
     if (empty($this->context->cart->id_carrier)) {
         $checked = $this->context->cart->simulateCarrierSelectedOutput();
         $checked = (int) Cart::desintifier($checked);
         $this->context->cart->id_carrier = $checked;
         $this->context->cart->update();
         CartRule::autoRemoveFromCart($this->context);
         CartRule::autoAddToCart($this->context);
     }
     // SHOPPING CART
     $this->_assignSummaryInformations();
     // WRAPPING AND TOS
     $this->_assignWrappingAndTOS();
     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, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => (int) Tools::getCountry(), 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'], 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), '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) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     // ADDRESS
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
     $this->context->smarty->assign('newsletter', $newsletter);
     $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
     $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
     $this->_processAddressFormat();
     $link = new Link();
     if (Tools::getValue('deleteFromOrderLine')) {
         $id_product = Tools::getValue('id_product');
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         $obj_cart_bk_data = new HotelCartBookingData();
         $cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to);
         if ($cart_data_dlt) {
             Tools::redirect($link->getPageLink('order', null, $this->context->language->id));
         }
     }
     if ((bool) Configuration::get('PS_ADVANCED_PAYMENT_API')) {
         $this->addJS(_THEME_JS_DIR_ . 'advanced-payment-api.js');
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl');
     } else {
         if (Module::isInstalled('hotelreservationsystem')) {
             require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
             $obj_cart_bk_data = new HotelCartBookingData();
             $obj_htl_bk_dtl = new HotelBookingDetail();
             $obj_rm_type = new HotelRoomType();
             $htl_rm_types = $this->context->cart->getProducts();
             if (!empty($htl_rm_types)) {
                 foreach ($htl_rm_types as $type_key => $type_value) {
                     $product = new Product($type_value['id_product'], false, $this->context->language->id);
                     $cover_image_arr = $product->getCover($type_value['id_product']);
                     if (!empty($cover_image_arr)) {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
                     } else {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
                     }
                     $unit_price = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                     if (isset($this->context->customer->id)) {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     } else {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     }
                     $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']);
                     $cart_htl_data[$type_key]['id_product'] = $type_value['id_product'];
                     $cart_htl_data[$type_key]['cover_img'] = $cover_img;
                     $cart_htl_data[$type_key]['name'] = $product->name;
                     $cart_htl_data[$type_key]['unit_price'] = $unit_price;
                     $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
                     $cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
                     foreach ($cart_bk_data as $data_k => $data_v) {
                         $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']);
                         if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
                             $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
                             $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $vart_quant;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                         } else {
                             $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $num_days;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['link'] = $link->getPageLink('order', null, $this->context->language->id, "id_product=" . $type_value['id_product'] . "&deleteFromOrderLine=1&date_from=" . $data_v['date_from'] . "&date_to=" . $data_v['date_to']);
                         }
                     }
                 }
                 $this->context->smarty->assign('cart_htl_data', $cart_htl_data);
             }
         }
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
     }
 }
 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');
         }
     }
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     // 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']) {
             $free_shipping = true;
             break;
         }
     }
     $this->context->smarty->assign(array('free_shipping' => $free_shipping, '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) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders()));
     /* Call a hook to display more information on form */
     self::$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) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // ADDRESS
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
     $this->_processAddressFormat();
     $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
 }
 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');
         }
     }
 }