Example #1
0
 function hookRightColumn($params)
 {
     global $smarty, $category_path;
     $category_path_ids = array();
     foreach ($category_path as $cat) {
         $category_path_ids[] = $cat['id_category'];
     }
     $currency = new Currency(intval($params['cookie']->id_currency));
     $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 25);
     $best_sellers = array();
     $nr = 0;
     foreach ($bestsellers as $bestseller) {
         if ($nr >= 5) {
             break;
         }
         $display = false;
         foreach (Product::getIndexedCategories($bestseller['id_product']) as $row) {
             if (in_array($row['id_category'], $category_path_ids)) {
                 $display = true;
                 break;
             }
         }
         if ($display) {
             $bestseller['price'] = Tools::displayPrice(Product::getPriceStaticLC(intval($bestseller['id_product'])), $currency, false, false);
             $best_sellers[] = $bestseller;
             $nr += 1;
         }
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'), 'static_token' => Tools::getToken(false)));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
 public function displayHeader()
 {
     global $css_files, $js_files;
     if (!self::$initialized) {
         $this->init();
     }
     // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
     header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
     /* Hooks are volontary out the initialize array (need those variables already assigned) */
     self::$smarty->assign(array('time' => time(), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int) Tools::getValue('content_only')));
     self::$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_BELOWNAVH' => Module::hookExec('belownavh'), 'HOOK_FILTERBY_CENTER' => Module::hookExec('filterbyCenter')));
     if ((Configuration::get('PS_CSS_THEME_CACHE') or Configuration::get('PS_JS_THEME_CACHE')) and is_writable(_PS_THEME_DIR_ . 'cache')) {
         // CSS compressor management
         if (Configuration::get('PS_CSS_THEME_CACHE')) {
             Tools::cccCss();
         }
         //JS compressor management
         if (Configuration::get('PS_JS_THEME_CACHE')) {
             Tools::cccJs();
         }
     }
     self::$smarty->assign('css_files', $css_files);
     self::$smarty->assign('js_files', array_unique($js_files));
     self::$smarty->display(_PS_THEME_DIR_ . 'header.tpl');
 }
Example #3
0
 function displayOrderStep($params)
 {
     global $smarty, $cart, $errors;
     $smarty->assign('errors', $errors);
     if (file_exists(_PS_SHIP_IMG_DIR_ . intval($cart->id_carrier) . '.jpg')) {
         $smarty->assign('carrierPicture', 1);
     }
     $cart->save();
     // Hack to get loyalty and other modules happy
     $summary = $cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas(intval($cart->id));
     Product::addCustomizationPrice($summary['products'], $customizedDatas);
     if ($free_ship = intval(Configuration::get('PS_SHIPPING_FREE_PRICE'))) {
         $discounts = $cart->getDiscounts();
         $total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
         foreach ($discounts as $discount) {
             if ($discount['id_discount_type'] == 3) {
                 $total_free_ship = 0;
                 break;
             }
         }
         $smarty->assign('free_ship', $total_free_ship);
     }
     $smarty->assign($summary);
     $token = Tools::getToken(false);
     $smarty->assign(array('token_cart' => $token, 'voucherAllowed' => Configuration::get('PS_VOUCHERS'), 'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary), 'shippingCost' => $cart->getOrderTotalLC(true, 5), 'shippingCostTaxExc' => $cart->getOrderTotalLC(false, 5), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'lastProductAdded' => $cart->getLastProduct()));
     Tools::safePostVars();
     include_once dirname(__FILE__) . '/../../header.php';
     echo $this->display(__FILE__, 'ordersummary.tpl');
 }
Example #4
0
 public function displayHeader()
 {
     global $css_files, $js_files;
     if (!self::$initialized) {
         $this->init();
     }
     // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
     header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
     /* Hooks are volontary out the initialize array (need those variables already assigned) */
     self::$smarty->assign(array('time' => time(), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int) Tools::getValue('content_only'), 'hide_left_column' => 0, 'hide_right_column' => 1));
     self::$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'), 'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'), 'HOOK_BHEAD_TOP' => Module::hookExec('displayBheadTop'), 'HOOK_BHEAD_BTM' => Module::hookExec('displayBheadBtm'), 'HOOK_BBODY_TOP' => Module::hookExec('displayBbodyTop'), 'HOOK_SIDE1_TOP' => Module::hookExec('displaySide1Top'), 'HOOK_SIDE1_BTM' => Module::hookExec('displaySide1Btm'), 'HOOK_MAIN_TOP' => Module::hookExec('displayMainTop'), 'HOOK_CONTENT_SIDE1' => Module::hookExec('displayContentSide1'), 'HOOK_CONTENT_TOP' => Module::hookExec('displayContentTop'), 'HOOK_CONTENT_BTM' => Module::hookExec('displayContentBtm'), 'HOOK_CONTENT_SIDE2' => Module::hookExec('displayContentSide2'), 'HOOK_MAIN_BTM' => Module::hookExec('displayMainBtm'), 'HOOK_SIDE2_TOP' => Module::hookExec('displaySide2Top'), 'HOOK_SIDE2_BTM' => Module::hookExec('displaySide2Btm')));
     $page_array_left = array("no-index", "no-search", "no-category", "prices-drop", "new-products", "all-products", "best-sales", "no-product", "order", "authentication", "my-account", "history", "orde//r-slip", "search", "identity", "discount", "sendtoafriend-form", "password", "addresses", "no-cms", "contact-form");
     self::$smarty->assign(array('page_array_left' => $page_array_left));
     $page_array_right = array("index", "no-search", "category", "prices-drop", "new-products", "all-products", "best-sales", "product", "order", "authentication", "my-account", "history", "orde//r-slip", "search", "identity", "discount", "sendtoafriend-form", "password", "addresses", "cms", "contact-form");
     self::$smarty->assign(array('page_array_right' => $page_array_right));
     if ((Configuration::get('PS_CSS_THEME_CACHE') || Configuration::get('PS_JS_THEME_CACHE')) && is_writable(_PS_THEME_DIR_ . 'cache')) {
         // CSS compressor management
         if (Configuration::get('PS_CSS_THEME_CACHE')) {
             Tools::cccCss();
         }
         // JS compressor management
         if (Configuration::get('PS_JS_THEME_CACHE')) {
             Tools::cccJs();
         }
     }
     self::$smarty->assign('css_files', $css_files);
     self::$smarty->assign('js_files', array_unique($js_files));
     self::$smarty->display(_PS_THEME_DIR_ . 'header.tpl');
 }
Example #5
0
 public function displayHeader()
 {
     if (!$this->instantSearch and !$this->ajaxSearch) {
         parent::displayHeader();
     } else {
         self::$smarty->assign('static_token', Tools::getToken(false));
     }
 }
Example #6
0
 /**
  * Returns module content for header
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookFooter($params)
 {
     global $smarty, $cookie, $cart;
     if (isset($smarty->_tpl_vars['HOOK_EXTRACARRIER']) and $smarty->_tpl_vars['page_name'] == 'order') {
         $smarty->assign('TNTCarrierId', $this->_id_carrier);
         //			if ($smarty->_tpl_vars['page_name'] == 'order')
         //				$smarty->assign('TNT_js', 'relaisColis');
         if ($smarty->_tpl_vars['page_name'] == 'history') {
             $smarty->assign('TNT_js', 'suiviColis');
         }
         return $this->display(__FILE__, 'relaistnt_footer.tpl');
     } elseif ($smarty->_tpl_vars['page_name'] == 'order' and (Tools::isSubmit('processCarrier') or Tools::getValue('step') === '3') and Validate::isLoadedObject($cart)) {
         if ($cart->id_carrier != intval($this->_id_carrier)) {
             return;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('token')) && $cookie->isLogged() === true) {
             $error = $this->l('invalid token');
         }
         $tntRCSelectedCode = pSQL(Tools::getValue('tntRCSelectedCode'));
         if (empty($tntRCSelectedCode) or is_null($tntRCSelectedCode)) {
             $error = $this->l('Avec la livraison TNT, vous devez choisir le relais dans lequel votre colis sera livrƩ.');
         }
         if (!isset($error)) {
             $address_TNT = new Address();
             $address_TNT->id_country = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
             $address_TNT->id_customer = intval($cart->id_customer);
             $address_TNT->alias = $this->l('TNT-') . $cart->id . '-' . $tntRCSelectedCode;
             $address_TNT->lastname = $this->l('TNT');
             $address_TNT->firstname = $this->l('Relais Colis');
             if (Validate::isName(Tools::getValue('tntRCSelectedNom'))) {
                 $address_TNT->company = pSQL(Tools::getValue('tntRCSelectedNom'));
                 $address_TNT->firstname .= ' - ' . pSQL(Tools::getValue('tntRCSelectedNom'));
             }
             if (Validate::isAddress(Tools::getValue('tntRCSelectedAdresse'))) {
                 $address_TNT->address1 = pSQL(Tools::getValue('tntRCSelectedAdresse'));
             }
             if (Validate::isPostCode(Tools::getValue('tntRCSelectedCodePostal'))) {
             }
             $address_TNT->postcode = pSQL(Tools::getValue('tntRCSelectedCodePostal'));
             if (Validate::isCityName(preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune'))))) {
                 $address_TNT->city = preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune')));
             }
             $address_TNT->deleted = 1;
             $errors = $address_TNT->validateControler();
             if (is_array($errors) and isset($errors[0])) {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($errors[0]));
             }
             if ($address_TNT->save()) {
                 $cart->id_address_delivery = intval($address_TNT->id);
                 $cart->save();
             } else {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($this->l('could not save TNT address')));
             }
         } else {
             Tools::redirect('order.php?step=2&error;=' . urlencode($error));
         }
     }
 }
Example #7
0
 /**
  * Assign wishlist template
  */
 public function assign()
 {
     $errors = array();
     if ($this->context->customer->isLogged()) {
         $add = Tools::getIsset('add');
         $add = empty($add) === false ? 1 : 0;
         $delete = Tools::getIsset('deleted');
         $delete = empty($delete) === false ? 1 : 0;
         $id_wishlist = Tools::getValue('id_wishlist');
         if (Tools::isSubmit('submitWishlist')) {
             if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) {
                 $errors[] = $this->module->l('Invalid token', 'mywishlist');
             }
             if (!sizeof($errors)) {
                 $name = Tools::getValue('name');
                 if (empty($name)) {
                     $errors[] = $this->module->l('You must specify a name.', 'mywishlist');
                 }
                 if (WishList::isExistsByNameForUser($name)) {
                     $errors[] = $this->module->l('This name is already used by another list.', 'mywishlist');
                 }
                 if (!sizeof($errors)) {
                     $wishlist = new WishList();
                     $wishlist->id_shop = $this->context->shop->id;
                     $wishlist->id_shop_group = $this->context->shop->id_shop_group;
                     $wishlist->name = $name;
                     $wishlist->id_customer = (int) $this->context->customer->id;
                     list($us, $s) = explode(' ', microtime());
                     srand($s * $us);
                     $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16));
                     $wishlist->add();
                     Mail::Send($this->context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $this->context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, $this->module->getLocalPath() . 'mails/');
                 }
             }
         } else {
             if ($add) {
                 WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id);
             } else {
                 if ($delete and empty($id_wishlist) === false) {
                     $wishlist = new WishList((int) $id_wishlist);
                     if (Validate::isLoadedObject($wishlist)) {
                         $wishlist->delete();
                     } else {
                         $errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist');
                     }
                 }
             }
         }
         $this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id));
         $this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id));
     } else {
         Tools::redirect('index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist')));
     }
     $this->context->smarty->assign(array('id_customer' => (int) $this->context->customer->id, 'errors' => $errors, 'form_link' => $errors));
     $this->setTemplate('mywishlist.tpl');
 }
 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id'];
             $productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id'];
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         /**
          * ABU edit: variable is_discount set Ć  1 Ć  tord, calcul foireux de presta
          * @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23
          * @perso: soustraction de l'ecotax au price_without_specific_price @else
          */
         if (Product::getTaxCalculationMethod()) {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
 public function displayHeader()
 {
     global $css_files, $js_files;
     if (!self::$initialized) {
         $this->init();
     }
     // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
     header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
     /* Hooks are volontary out the initialize array (need those variables already assigned) */
     self::$smarty->assign(array('time' => time(), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int) Tools::getValue('content_only')));
     self::$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')));
     if ((Configuration::get('PS_CSS_THEME_CACHE') or Configuration::get('PS_JS_THEME_CACHE')) and is_writable(_PS_THEME_DIR_ . 'cache')) {
         // CSS compressor management
         if (Configuration::get('PS_CSS_THEME_CACHE')) {
             Tools::cccCss();
         }
         //JS compressor management
         if (Configuration::get('PS_JS_THEME_CACHE')) {
             Tools::cccJs();
         }
     }
     /*pl*/
     $tags_name = Tools::getValue('pltn');
     self::$smarty->assign('meta_title', $tags_name . ' - Blog ');
     // $id_pl_blog_category = (int) Tools::getValue('plidc');
     // if ($id_pl_blog_category != null)
     // {
     // $category = $this->getMetaCategoryById($id_pl_blog_category);
     // $meta_title = $category['category_meta_title'];
     // $meta_description = $category['category_meta_description'];
     // $meta_keywords = $category['category_meta_keywords'];
     // if ($meta_title != null)
     // self::$smarty->assign('meta_title', $meta_title.' - Blog ');
     // if ($meta_description != null)
     // self::$smarty->assign('meta_description',$meta_description);
     // if ($meta_keywords != null)
     // self::$smarty->assign('meta_keywords', $meta_keywords);
     // }
     // else
     // {
     // $category_name = 'List post';
     // self::$smarty->assign('meta_title', $category_name.' - Blog ');
     // }
     /* -pl */
     self::$smarty->assign('css_files', $css_files);
     self::$smarty->assign('js_files', array_unique($js_files));
     self::$smarty->display(_PS_THEME_DIR_ . 'header.tpl');
 }
Example #10
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $presenter = new CartPresenter();
     $presented_cart = $presenter->present($this->context->cart);
     $this->context->smarty->assign(['cart' => $presented_cart, 'static_token' => Tools::getToken(false)]);
     if (count($presented_cart['products']) > 0) {
         $this->setTemplate('checkout/cart');
     } else {
         $this->context->smarty->assign(['allProductsLink' => $this->context->link->getCategoryLink(Configuration::get('PS_HOME_CATEGORY'))]);
         $this->setTemplate('checkout/cart-empty');
     }
 }
Example #11
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->assignCountries();
     $this->assignVatNumber();
     $this->assignAddressFormat();
     // Assign common vars
     $this->context->smarty->assign(array('one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'onr_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'ajaxurl' => _MODULE_DIR_, 'errors' => $this->errors, 'token' => Tools::getToken(false), 'select_address' => (int) Tools::getValue('select_address'), 'address' => $this->_address, 'id_address' => Validate::isLoadedObject($this->_address) ? $this->_address->id : 0));
     if ($back = Tools::getValue('back')) {
         $this->context->smarty->assign('back', Tools::safeOutput($back));
     }
     if ($mod = Tools::getValue('mod')) {
         $this->context->smarty->assign('mod', Tools::safeOutput($mod));
     }
     if (isset($this->context->cookie->account_created)) {
         $this->context->smarty->assign('account_created', 1);
         unset($this->context->cookie->account_created);
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'address.tpl');
 }
Example #12
0
 public function ajaxCall()
 {
     global $smarty, $cookie;
     $selected_filters = $this->getSelectedFilters();
     $filter_block = $this->getFilterBlock($selected_filters);
     $this->getProducts($selected_filters, $products, $nb_products, $p, $n, $pages_nb, $start, $stop, $range, $combinations);
     // Add pagination variable
     $nArray = (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
     // Clean duplicate values
     $nArray = array_unique($nArray);
     asort($nArray);
     if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
         $this->context->controller->addColorsToProductList($products);
     }
     $category = new Category(Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY')), (int) $cookie->id_lang);
     // Generate meta title and meta description
     $category_title = empty($category->meta_title) ? $category->name : $category->meta_title;
     $category_metas = Meta::getMetaTags((int) $cookie->id_lang, 'category');
     $title = '';
     $keywords = '';
     if (is_array($filter_block['title_values'])) {
         foreach ($filter_block['title_values'] as $key => $val) {
             $title .= ' > ' . $key . ' ' . implode('/', $val);
             $keywords .= $key . ' ' . implode('/', $val) . ', ';
         }
     }
     $title = $category_title . $title;
     if (!empty($title)) {
         $meta_title = $title;
     } else {
         $meta_title = $category_metas['meta_title'];
     }
     $meta_description = $category_metas['meta_description'];
     $keywords = substr(strtolower($keywords), 0, 1000);
     if (!empty($keywords)) {
         $meta_keywords = rtrim($category_title . ', ' . $keywords . ', ' . $category_metas['meta_keywords'], ', ');
     }
     $smarty->assign(array('homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'nb_products' => $nb_products, 'category' => $category, 'pages_nb' => (int) $pages_nb, 'p' => (int) $p, 'n' => (int) $n, 'range' => (int) $range, 'start' => (int) $start, 'stop' => (int) $stop, 'n_array' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'products' => $products, 'products_per_page' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 'static_token' => Tools::getToken(false), 'page_name' => 'category', 'nArray' => $nArray, 'compareProducts' => CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare), 'combinations' => $combinations));
     // Prevent bug with old template where category.tpl contain the title of the category and category-count.tpl do not exists
     if (file_exists(_PS_THEME_DIR_ . 'category-count.tpl')) {
         $category_count = $smarty->fetch(_PS_THEME_DIR_ . 'category-count.tpl');
     } else {
         $category_count = '';
     }
     if ($nb_products == 0) {
         $product_list = $this->display(__FILE__, 'blocklayered-no-products.tpl');
     } else {
         $product_list = $smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
     }
     $vars = array('filtersBlock' => utf8_encode($this->generateFiltersBlock($selected_filters)), 'productList' => utf8_encode($product_list), 'pagination' => $smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'), 'categoryCount' => $category_count, 'meta_title' => $meta_title . ' - ' . Configuration::get('PS_SHOP_NAME'), 'heading' => $meta_title, 'meta_keywords' => isset($meta_keywords) ? $meta_keywords : null, 'meta_description' => $meta_description, 'current_friendly_url' => (int) $n == (int) $nb_products ? '#/show-all' : '#' . $filter_block['current_friendly_url'], 'filters' => $filter_block['filters'], 'nbRenderedProducts' => (int) $nb_products, 'nbAskedProducts' => (int) $n, 'combinations' => $combinations);
     if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
         $vars = array_merge($vars, array('pagination_bottom' => $smarty->assign('paginationId', 'bottom')->fetch(_PS_THEME_DIR_ . 'pagination.tpl')));
     }
     /* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */
     return Tools::jsonEncode($vars);
 }
Example #13
0
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision$
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/WishList.php';
$context = Context::getContext();
// Instance of module class for translations
$module = new BlockWishList();
if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and $context->customer->isLogged() === true) {
    exit($module->l('invalid token', 'sendwishlist'));
}
if ($context->customer->isLogged()) {
    $id_wishlist = (int) Tools::getValue('id_wishlist');
    if (empty($id_wishlist) === true) {
        exit($module->l('Invalid wishlist', 'sendwishlist'));
    }
    for ($i = 1; empty($_POST['email' . strval($i)]) === false; ++$i) {
        $to = Tools::getValue('email' . $i);
        $wishlist = WishList::exists($id_wishlist, $context->customer->id, true);
        if ($wishlist === false) {
            exit($module->l('Invalid wishlist', 'sendwishlist'));
        }
        if (WishList::addEmail($id_wishlist, $to) === false) {
            exit($module->l('Wishlist send error', 'sendwishlist'));
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         // If the product is not active, it's the admin preview mode
         if (!$this->product->active) {
             $this->context->smarty->assign('adminActionDisplay', true);
         }
         // Product pictures management
         require_once 'images.inc.php';
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } else {
             if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
             }
         }
         $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
         $pictures = array();
         foreach ($files as $file) {
             $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
         }
         $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
         $text_fields = array();
         foreach ($texts as $text_field) {
             $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons'), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK')));
     }
     $this->context->smarty->assign('errors', $this->errors);
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
 public function preProcess()
 {
     parent::preProcess();
     if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
         Tools::redirect('my-account.php');
     }
     if (Tools::getValue('create_account')) {
         $create_account = 1;
         self::$smarty->assign('email_create', 1);
     }
     if (Tools::isSubmit('SubmitCreate')) {
         if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (Customer::customerExists($email)) {
             $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             $_POST['email'] = $_POST['email_create'];
             unset($_POST['email_create']);
         } else {
             $create_account = 1;
             self::$smarty->assign('email_create', Tools::safeOutput($email));
             $_POST['email'] = $email;
         }
     }
     if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
         $create_account = 1;
         if (Tools::isSubmit('submitAccount')) {
             self::$smarty->assign('email_create', 1);
         }
         /* New Guest customer */
         if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $this->errors[] = Tools::displayError('You cannot create a guest account.');
         }
         if (!Tools::getValue('is_new_customer', 1)) {
             $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
         }
         if (isset($_POST['guest_email']) and $_POST['guest_email']) {
             $_POST['email'] = $_POST['guest_email'];
         }
         /* Preparing customer */
         $customer = new Customer();
         $lastnameAddress = $_POST['lastname'];
         $firstnameAddress = $_POST['firstname'];
         $_POST['lastname'] = $_POST['customer_lastname'];
         $_POST['firstname'] = $_POST['customer_firstname'];
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
         $this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
         /* Preparing address */
         $address = new Address();
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $address->id_customer = 1;
         $this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         $zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country'));
         if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) {
             if ($postcode = Tools::getValue('postcode') and $zip_code_format) {
                 $zip_regexp = '/^' . $zip_code_format . '$/ui';
                 $zip_regexp = str_replace(' ', '( |)', $zip_regexp);
                 $zip_regexp = str_replace('-', '(-|)', $zip_regexp);
                 $zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
                 $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
                 $zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp);
                 if (!preg_match($zip_regexp, $postcode)) {
                     $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
                 }
             } elseif ($zip_code_format) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
             } elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
             }
         }
         if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!Country::isNeedDniByCountryId($address->id_country)) {
             $address->dni = NULL;
         }
         if (!sizeof($this->errors)) {
             if (Customer::customerExists(Tools::getValue('email'))) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             }
             if (Tools::isSubmit('newsletter')) {
                 $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
                 $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
             }
             if (!sizeof($this->errors)) {
                 if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) {
                     die(Tools::displayError());
                 }
                 if ((int) $country->contains_states and !(int) $address->id_state) {
                     $this->errors[] = Tools::displayError('This country requires a state selection.');
                 } else {
                     $customer->active = 1;
                     /* New Guest customer */
                     if (Tools::isSubmit('is_new_customer')) {
                         $customer->is_guest = !Tools::getValue('is_new_customer', 1);
                     } else {
                         $customer->is_guest = 0;
                     }
                     if (!$customer->add()) {
                         $this->errors[] = Tools::displayError('An error occurred while creating your account.');
                     } else {
                         $address->id_customer = (int) $customer->id;
                         if (!$address->add()) {
                             $this->errors[] = Tools::displayError('An error occurred while creating your address.');
                         } else {
                             if (!$customer->is_guest) {
                                 if (!Mail::Send((int) self::$cookie->id_lang, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                                     $this->errors[] = Tools::displayError('Cannot send email');
                                 }
                             }
                             self::$smarty->assign('confirmation', 1);
                             self::$cookie->id_customer = (int) $customer->id;
                             self::$cookie->customer_lastname = $customer->lastname;
                             self::$cookie->customer_firstname = $customer->firstname;
                             self::$cookie->passwd = $customer->passwd;
                             self::$cookie->logged = 1;
                             self::$cookie->email = $customer->email;
                             self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1);
                             /* Update cart address */
                             self::$cart->secure_key = $customer->secure_key;
                             self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->update();
                             Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                             if (Tools::isSubmit('ajax')) {
                                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'id_address_delivery' => self::$cart->id_address_delivery, 'id_address_invoice' => self::$cart->id_address_invoice, 'token' => Tools::getToken(false));
                                 die(Tools::jsonEncode($return));
                             }
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirect($back);
                             }
                             Tools::redirect('my-account.php');
                         }
                     }
                 }
             }
         }
         if (sizeof($this->errors)) {
             if (!Tools::getValue('is_new_customer')) {
                 unset($_POST['passwd']);
             }
             if (Tools::isSubmit('ajax')) {
                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0);
                 die(Tools::jsonEncode($return));
             }
         }
     }
     if (Tools::isSubmit('SubmitLogin')) {
         Module::hookExec('beforeAuthentication');
         $passwd = trim(Tools::getValue('passwd'));
         $email = trim(Tools::getValue('email'));
         if (empty($email)) {
             $this->errors[] = Tools::displayError('E-mail address required');
         } elseif (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (empty($passwd)) {
             $this->errors[] = Tools::displayError('Password is required');
         } elseif (Tools::strlen($passwd) > 32) {
             $this->errors[] = Tools::displayError('Password is too long');
         } elseif (!Validate::isPasswd($passwd)) {
             $this->errors[] = Tools::displayError('Invalid password');
         } else {
             $customer = new Customer();
             $authentication = $customer->getByEmail(trim($email), trim($passwd));
             if (!$authentication or !$customer->id) {
                 /* Handle brute force attacks */
                 sleep(1);
                 $this->errors[] = Tools::displayError('Authentication failed');
             } else {
                 self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id);
                 self::$cookie->id_customer = (int) $customer->id;
                 self::$cookie->customer_lastname = $customer->lastname;
                 self::$cookie->customer_firstname = $customer->firstname;
                 self::$cookie->id_default_group = $customer->id_default_group;
                 self::$cookie->logged = 1;
                 self::$cookie->is_guest = $customer->isGuest();
                 self::$cookie->passwd = $customer->passwd;
                 self::$cookie->email = $customer->email;
                 if (Configuration::get('PS_CART_FOLLOWING') and (empty(self::$cookie->id_cart) or Cart::getNbProducts(self::$cookie->id_cart) == 0)) {
                     self::$cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id);
                 }
                 /* Update cart address */
                 self::$cart->id_carrier = 0;
                 self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                 self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                 // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
                 self::$cart->secure_key = $customer->secure_key;
                 self::$cart->update();
                 Module::hookExec('authentication');
                 if (!Tools::isSubmit('ajax')) {
                     if ($back = Tools::getValue('back')) {
                         Tools::redirect($back);
                     }
                     Tools::redirect('my-account.php');
                 }
             }
         }
         if (Tools::isSubmit('ajax')) {
             $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false));
             die(Tools::jsonEncode($return));
         }
     }
     if (isset($create_account)) {
         /* Select the most appropriate country */
         if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
             $selectedCountry = (int) $_POST['id_country'];
         }
         /* FIXME : language iso and country iso are not similar,
         			 * maybe an associative table with country an language can resolve it,
         			 * But for now it's a bug !
         			 * @see : bug #6968
         			 * @link:http://www.prestashop.com/bug_tracker/view/6968/
         			elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
         			{
         				$array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         				if (Validate::isLanguageIsoCode($array[0]))
         				{
         					$selectedCountry = Country::getByIso($array[0]);
         					if (!$selectedCountry)
         						$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
         				}
         			}*/
         if (!isset($selectedCountry)) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true);
         } else {
             $countries = Country::getCountries((int) self::$cookie->id_lang, true);
         }
         self::$smarty->assign(array('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT')));
         /* Call a hook to display more information on form */
         self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
     }
     /* Generate years, months and days */
     if (isset($_POST['years']) and is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) and is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) and is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
Example #16
0
 public function hookRightColumn($params)
 {
     global $errors;
     require_once dirname(__FILE__) . '/WishList.php';
     if ($this->context->customer->isLogged()) {
         $wishlists = Wishlist::getByIdCustomer($this->context->customer->id);
         if (empty($this->context->cookie->id_wishlist) === true || WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) {
             if (!sizeof($wishlists)) {
                 $id_wishlist = false;
             } else {
                 $id_wishlist = (int) $wishlists[0]['id_wishlist'];
                 $this->context->cookie->id_wishlist = (int) $id_wishlist;
             }
         } else {
             $id_wishlist = $this->context->cookie->id_wishlist;
         }
         $this->smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'wishlist_products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false)));
     } else {
         $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false));
     }
     $this->smarty->assign(array('wishlist_link' => $this->context->link->getModuleLink('blockwishlist', 'mywishlist')));
     return $this->display(__FILE__, 'blockwishlist.tpl');
 }
 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) (isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
             $productAttributeId = (int) (isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], 2, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         if (Product::getTaxCalculationMethod()) {
             $product['is_discounted'] = $product['price_without_specific_price'] != $product['price'];
         } else {
             $product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt'];
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], 'BO_ORDER_') === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
Example #18
0
 public function hookRightColumn($params)
 {
     if ($this->context->customer->isLogged()) {
         $wishlists = Wishlist::getByIdCustomer($this->context->customer->id);
         if (empty($this->context->cookie->id_wishlist) === true || WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) {
             if (!count($wishlists)) {
                 $id_wishlist = false;
             } else {
                 $id_wishlist = (int) $wishlists[0]['id_wishlist'];
                 $this->context->cookie->id_wishlist = (int) $id_wishlist;
             }
         } else {
             $id_wishlist = $this->context->cookie->id_wishlist;
         }
         $this->smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'wishlist_products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false)));
     } else {
         $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false));
     }
     return $this->display(__FILE__, 'blockwishlist.tpl');
 }
 public function process()
 {
     global $cart, $currency;
     parent::process();
     if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) {
         $this->errors[] = Tools::displayError('Product not found');
     } else {
         if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) {
             header('HTTP/1.1 404 page not found');
             $this->errors[] = Tools::displayError('Product is no longer available.');
         } elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) {
             $this->errors[] = Tools::displayError('You do not have access to this product.');
         } else {
             self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
             if (!$this->product->active) {
                 self::$smarty->assign('adminActionDisplay', true);
             }
             /* rewrited url set */
             $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
             /* Product pictures management */
             require_once 'images.inc.php';
             self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
             if (Tools::isSubmit('submitCustomizedDatas')) {
                 $this->pictureUpload($this->product, $cart);
                 $this->textRecord($this->product, $cart);
                 $this->formTargetFormat();
             } elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
             }
             $files = self::$cookie->getFamily('pictures_' . (int) $this->product->id);
             $textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id);
             foreach ($textFields as $key => $textField) {
                 $textFields[$key] = str_replace('<br />', "\n", $textField);
             }
             self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
             if ((int) Tools::getValue('pp') == 1) {
                 echo 'here1';
             }
             $productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6);
             if (Product::$_taxCalculationMethod == PS_TAX_INC) {
                 $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time2 = time();
                 echo 'time2: ' . $time2;
             }
             $productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
             $configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES'));
             /* Features / Values */
             $features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
             $attachments = $this->product->getAttachments((int) self::$cookie->id_lang);
             /* Category */
             $category = false;
             if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
                 if (isset($regs[2]) and is_numeric($regs[2])) {
                     if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) {
                         $category = new Category((int) $regs[2], (int) self::$cookie->id_lang);
                     }
                 } elseif (isset($regs[5]) and is_numeric($regs[5])) {
                     if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) {
                         $category = new Category((int) $regs[5], (int) self::$cookie->id_lang);
                     }
                 }
             }
             if (!$category) {
                 $category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang);
             }
             if (isset($category) and Validate::isLoadedObject($category)) {
                 self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name)));
             } else {
                 self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
             }
             self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
             $lang = Configuration::get('PS_LANG_DEFAULT');
             if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) {
                 $this->product->quantity = 0;
             }
             $group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100;
             $id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
             $id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
             $id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
             if ((int) Tools::getValue('pp') == 1) {
                 $time3 = time();
                 echo 'time3: ' . $time3;
             }
             // Tax
             $tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             self::$smarty->assign('tax_rate', $tax);
             $ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
             if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
                 $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
             }
             $manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1);
             $sizechart = new Sizechart((int) $this->product->id_sizechart, 1);
             //see if the product is already in the wishlist
             if ($id_customer) {
                 $sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id;
                 $res = Db::getInstance()->ExecuteS($sql);
                 if ($res) {
                     self::$smarty->assign("in_wishlist", true);
                 } else {
                     self::$smarty->assign("in_wishlist", false);
                 }
             } else {
                 self::$smarty->assign("in_wishlist", false);
             }
             self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => $manufacturer, 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) $configs['PS_LAST_QTIES'], 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_, 'sizechart' => $sizechart->sizechart, 'sizechart_data' => $sizechart->sizechart_data));
             self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
             if ((int) Tools::getValue('pp') == 1) {
                 $time4 = time();
                 echo 'time4: ' . $time4;
             }
             $images = $this->product->getImages((int) self::$cookie->id_lang);
             $productImages = array();
             foreach ($images as $k => $image) {
                 if ($image['cover']) {
                     self::$smarty->assign('mainImage', $images[0]);
                     $cover = $image;
                     $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
                     $cover['id_image_only'] = (int) $image['id_image'];
                 }
                 $productImages[(int) $image['id_image']] = $image;
             }
             if (!isset($cover)) {
                 $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
             }
             $size = Image::getSize('large');
             self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang)));
             if (sizeof($productImages)) {
                 self::$smarty->assign('images', $productImages);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time5 = time();
                 echo 'time5: ' . $time5;
             }
             /* Attributes / Groups & colors */
             $colors = array();
             //see if the product has shades
             if ($this->product->id_group && $this->product->id_group > 0) {
                 global $link;
                 $related_productIds = $this->product->getRelatedProducts();
                 $related_products = array();
                 foreach ($related_productIds as &$productId) {
                     $relProduct = new Product((int) $productId['id_product'], true, self::$cookie->id_lang);
                     $idImage = $relProduct->getCoverWs();
                     if ($idImage) {
                         $idImage = $relProduct->id . '-' . $idImage;
                     } else {
                         $idImage = Language::getIsoById(1) . '-default';
                     }
                     $relProduct->image_link = $link->getImageLink($relProduct->link_rewrite, $idImage, 'small');
                     $relProduct->link = $relProduct->getLink();
                     $related_products[] = $relProduct;
                 }
                 self::$smarty->assign('relatedProducts', $related_products);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time6 = time();
                 echo 'time6: ' . $time6;
             }
             $attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang);
             // @todo (RM) should only get groups and not all declination ?
             if (is_array($attributesGroups) and $attributesGroups) {
                 $groups = array();
                 $combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang);
                 foreach ($attributesGroups as $k => $row) {
                     /* Color management */
                     if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) {
                         $colors[$row['id_attribute']]['value'] = $row['attribute_color'];
                         $colors[$row['id_attribute']]['name'] = $row['attribute_name'];
                         if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) {
                             $colors[$row['id_attribute']]['attributes_quantity'] = 0;
                         }
                         $colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity'];
                     }
                     if (!isset($groups[$row['id_attribute_group']])) {
                         $groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1);
                     }
                     $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
                     if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) {
                         $groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
                     }
                     if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) {
                         $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
                     }
                     $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];
                     $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
                     $combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
                     $combinations[$row['id_product_attribute']]['price'] = (double) $row['price'];
                     $combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax'];
                     $combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight'];
                     $combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity'];
                     $combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
                     $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
                     $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
                     $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
                 }
                 if ((int) Tools::getValue('pp') == 1) {
                     $time7 = time();
                     echo 'time7: ' . $time7;
                 }
                 //wash attributes list (if some attributes are unavailables and if allowed to wash it)
                 if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
                     foreach ($groups as &$group) {
                         foreach ($group['attributes_quantity'] as $key => &$quantity) {
                             if (!$quantity) {
                                 unset($group['attributes'][$key]);
                             }
                         }
                     }
                     foreach ($colors as $key => $color) {
                         if (!$color['attributes_quantity']) {
                             unset($colors[$key]);
                         }
                     }
                 }
                 if ((int) Tools::getValue('pp') == 1) {
                     $time71 = time();
                     echo 'time71: ' . $time71;
                 }
                 foreach ($groups as &$group) {
                     natcasesort($group['attributes']);
                 }
                 foreach ($combinations as $id_product_attribute => $comb) {
                     $attributeList = '';
                     foreach ($comb['attributes'] as $id_attribute) {
                         $attributeList .= '\'' . (int) $id_attribute . '\',';
                     }
                     $attributeList = rtrim($attributeList, ',');
                     $combinations[$id_product_attribute]['list'] = $attributeList;
                 }
                 self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time72 = time();
                 echo 'time72: ' . $time72;
             }
             //$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc');
             /*$categoryProducts = $this->getRandomCatProducts();
               self::$smarty->assign('cat_products', $categoryProducts);*/
             //$brandProducts = $this->getRandomBrandProducts();
             //self::$smarty->assign('brand_products', $brandProducts);
             if ((int) Tools::getValue('pp') == 1) {
                 $time73 = time();
                 echo ' time73: ' . $time73;
             }
             self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang)));
             if ((int) Tools::getValue('pp') == 1) {
                 $time74 = time();
                 echo 'time74: ' . $time74;
             }
             // Pack management
             self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
             self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
             if ((int) Tools::getValue('pp') == 1) {
                 print_r('pack done');
             }
         }
     }
     if ((int) Tools::getValue('pp') == 1) {
         $time8 = time();
         echo 'time8: ' . $time8;
     }
     if ($this->is_saree || $this->is_lehenga) {
         if ($this->is_lehenga) {
             self::$smarty->assign('is_lehenga', $this->is_lehenga);
         }
         self::$smarty->assign('as_shown', (bool) $this->product->as_shown);
         /*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1))
               self::$smarty->assign('measurement_info', $blouse_measurements);
           if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2))
               self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/
         if ((int) Tools::getValue('pp') == 1) {
             $time81 = time();
             echo 'time81: ' . $time81;
         }
         if ($this->is_saree) {
             //count of all styles mapped to this product
             $res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1");
             $style_count = (int) $res['style_count'];
             if ($style_count === 0) {
                 // show the default style for sarees
                 $style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round');
             } else {
                 $res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small  from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1");
                 if (!empty($res)) {
                     //show the default style for this product
                     $style = array('id_style' => $res['id_style'], 'style_image_small' => $res['style_image_small'], 'style_name' => $res['style_name']);
                 }
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time82 = time();
                 echo 'time82: ' . $time82;
             }
             self::$smarty->assign('blouse_style_count', $style_count);
             self::$smarty->assign('blouse_style', $style);
         }
     } else {
         if ($this->is_skd || $this->is_skd_rts) {
             self::$smarty->assign('is_anarkali', $this->is_anarkali);
             if ($this->is_anarkali) {
                 if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 5)) {
                     self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
                 }
             } else {
                 if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 3)) {
                     self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
                 }
             }
             if ($salwar_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 4)) {
                 self::$smarty->assign('salwar_measurement_info', $salwar_measurements);
             }
             //get default styles for this product (RTS)
             if ($this->is_skd_rts) {
                 $res = Db::getInstance()->ExecuteS("select count(s.id_style) as style_count, s.style_type, ps.id_product from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} group by ps.id_product,s.style_type");
                 foreach ($res as $s) {
                     $style_count = (int) $s['style_count'];
                     if ((int) $s['style_type'] === 4) {
                         self::$smarty->assign('kurta_style_count', $style_count);
                     } else {
                         if ((int) $s['style_type'] === 5) {
                             self::$smarty->assign('salwar_style_count', $style_count);
                         }
                     }
                 }
                 $res = Db::getInstance()->ExecuteS("select s.id_style, s.style_type, s.style_image_small, s.style_name from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and ps.is_default = 1");
                 foreach ($res as $s) {
                     $style = array('id_style' => $s['id_style'], 'style_image_small' => $s['style_image_small'], 'style_name' => $s['style_name']);
                     if ((int) $s['style_type'] === 4) {
                         self::$smarty->assign('kurta_style', $style);
                     } else {
                         if ((int) $s['style_type'] === 5) {
                             self::$smarty->assign('salwar_style', $style);
                         }
                     }
                 }
             }
         }
     }
     self::$smarty->assign('is_bottoms', $this->is_bottoms);
     self::$smarty->assign('is_abaya', $this->is_abaya);
     self::$smarty->assign('is_wristwear', $this->is_wristwear);
     self::$smarty->assign('is_pakistani_rts', $this->is_pakistani_rts);
     if ((int) Tools::getValue('pp') == 1) {
         $time85 = time();
         echo 'time85: ' . $time85;
     }
     self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => Product::getCover((int) Tools::getValue('id_product')), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')));
     if ((int) Tools::getValue('pp') == 1) {
         $time9 = time();
         echo 'time9: ' . $time9;
     }
     //add this to product stats
     //Tools::captureActivity(PSTAT_VIEWS,$id_product);
     if ((int) Tools::getValue('pp') == 1) {
         $time1 = time();
         echo 'process end: ' . $time1;
     }
 }
Example #20
0
 public function ajaxCall()
 {
     //sleep(1);
     global $smarty, $cookie;
     $selectedFilters = $this->getSelectedFilters();
     $id_parent = (int) Tools::getValue('id_category', Tools::getValue('id_category_layered', 1));
     $id_manufacturer = Tools::getValue('id_manufacturer', false);
     $sortInfo = '';
     if (Tools::getValue('orderby') && Tools::getValue('orderway')) {
         $sortInfo = Tools::getProductsOrder('by', Tools::getValue('orderby')) . ':' . Tools::getProductsOrder('way', Tools::getValue('orderway'));
     }
     //echo print_r($selectedFilters);
     //$products = $this->getProductByFilters($selectedFilters);
     $resultSet = $this->getResults($id_parent, $this->search_query, $id_manufacturer, $selectedFilters);
     $products = $resultSet->getData();
     $products = $products['response']['docs'];
     $nbProducts = $resultSet->getNumFound();
     $range = 3;
     /* how many pages around page selected */
     $n = (int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
     $p = Tools::getValue('p', 1);
     if ($p < 0) {
         $p = 0;
     }
     if ($p > $nbProducts / $n) {
         $p = ceil($nbProducts / $n);
     }
     $pages_nb = ceil($nbProducts / (int) $n);
     $start = (int) ($p - $range);
     if ($start < 1) {
         $start = 1;
     }
     $stop = (int) ($p + $range);
     if ($stop > $pages_nb) {
         $stop = (int) $pages_nb;
     }
     $smarty->assign('nb_products', $nbProducts);
     $pagination_infos = array('pages_nb' => (int) $pages_nb, 'p' => (int) $p, 'n' => (int) $n, 'range' => (int) $range, 'start' => (int) $start, 'stop' => (int) $stop, 'nArray' => $nArray = (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50));
     $smarty->assign($pagination_infos);
     $smarty->assign('static_token', Tools::getToken(false));
     $smarty->assign('products', $products);
     $category = new Category((int) $id_parent);
     $selectedCategory = $category->getName(1);
     $productsTitle = $this->search_query ? $this->search_query : ($id_manufacturer ? Manufacturer::getNameById($id_manufacturer, 1) : $selectedCategory);
     $smarty->assign('lazy', 0);
     $nextPage = $p + 1;
     if ($p == $stop) {
         $nextPage = 0;
     }
     $smarty->assign('nextPage', $nextPage);
     $autoLoad = Tools::getValue('al', false);
     header('Content-type: application/json');
     if ($cookie->image_size == IMAGE_SIZE_LARGE) {
         $productListContent = $smarty->fetch(_PS_THEME_DIR_ . 'product-list-page.tpl');
     } else {
         $productListContent = $smarty->fetch(_PS_THEME_DIR_ . 'product-list-page-small.tpl');
     }
     if ($autoLoad) {
         $smarty->assign('autoload', 1);
         return Tools::jsonEncode(array('productList' => $productListContent, 'nextPage' => $nextPage));
     } else {
         $smarty->assign('autoload', 0);
         return Tools::jsonEncode(array('filtersBlock' => $this->generateFiltersBlock($selectedFilters), 'productList' => $productListContent, 'pagination' => $smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'), 'totalItems' => $nbProducts, 'sortInfo' => $sortInfo, 'productsTitle' => $productsTitle, 'nextPage' => $nextPage));
     }
     //	return '<div id="layered_ajax_column">'.$this->generateFiltersBlock($selectedFilters).'</div><div id="layered_ajax_products">'.$smarty->fetch(_PS_THEME_DIR_.'product-list.tpl').'</div>';
 }
Example #21
0
 public function ajaxCall()
 {
     global $smarty, $cookie;
     $selected_filters = $this->getSelectedFilters();
     $this->getProducts($selected_filters, $products, $nb_products, $p, $n, $pages_nb, $start, $stop, $range);
     // Add pagination variable
     $nArray = (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
     // Clean duplicate values
     $nArray = array_unique($nArray);
     asort($nArray);
     $smarty->assign(array('homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'nb_products' => $nb_products, 'category' => new Category(Tools::getValue('id_category_layered', 1), (int) $cookie->id_lang), 'pages_nb' => (int) $pages_nb, 'p' => (int) $p, 'n' => (int) $n, 'range' => (int) $range, 'start' => (int) $start, 'stop' => (int) $stop, 'n_array' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'products' => $products, 'products_per_page' => (int) Configuration::get('PS_PRODUCTS_PER_PAGE'), 'static_token' => Tools::getToken(false), 'page_name' => 'category', 'nArray' => $nArray));
     // Prevent bug with old template where category.tpl contain the title of the category and category-count.tpl do not exists
     if (file_exists(_PS_THEME_DIR_ . 'category-count.tpl')) {
         $category_count = $smarty->fetch(_PS_THEME_DIR_ . 'category-count.tpl');
     } else {
         $category_count = '';
     }
     if ($nb_products == 0) {
         $product_list = $this->display(__FILE__, 'blocklayered-no-products.tpl');
     } else {
         $product_list = $smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
     }
     /* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */
     return Tools::jsonEncode(array('filtersBlock' => utf8_encode($this->generateFiltersBlock($selected_filters)), 'productList' => utf8_encode($product_list), 'pagination' => $smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'), 'categoryCount' => $category_count));
 }
Example #22
0
 public function assignContentVars($params)
 {
     global $errors;
     // Set currency
     if ((int) $params['cart']->id_currency && (int) $params['cart']->id_currency != $this->context->currency->id) {
         $currency = new Currency((int) $params['cart']->id_currency);
     } else {
         $currency = $this->context->currency;
     }
     $taxCalculationMethod = Group::getPriceDisplayMethod((int) Group::getCurrent()->id);
     $useTax = !($taxCalculationMethod == PS_TAX_EXC);
     $products = $params['cart']->getProducts(true);
     $nbTotalProducts = 0;
     foreach ($products as $product) {
         $nbTotalProducts += (int) $product['cart_quantity'];
     }
     $cart_rules = $params['cart']->getCartRules();
     if (empty($cart_rules)) {
         $base_shipping = $params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING);
     } else {
         $base_shipping_with_tax = $params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING);
         $base_shipping_without_tax = $params['cart']->getOrderTotal(false, Cart::ONLY_SHIPPING);
         if ($useTax) {
             $base_shipping = $base_shipping_with_tax;
         } else {
             $base_shipping = $base_shipping_without_tax;
         }
     }
     $shipping_cost = Tools::displayPrice($base_shipping, $currency);
     $shipping_cost_float = Tools::convertPrice($base_shipping, $currency);
     $wrappingCost = (double) $params['cart']->getOrderTotal($useTax, Cart::ONLY_WRAPPING);
     $totalToPay = $params['cart']->getOrderTotal($useTax);
     if ($useTax && Configuration::get('PS_TAX_DISPLAY') == 1) {
         $totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false);
         $this->smarty->assign('tax_cost', Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency));
     }
     // The cart content is altered for display
     foreach ($cart_rules as &$cart_rule) {
         if ($cart_rule['free_shipping']) {
             $shipping_cost = Tools::displayPrice(0, $currency);
             $shipping_cost_float = 0;
             $cart_rule['value_real'] -= Tools::convertPrice($base_shipping_with_tax, $currency);
             $cart_rule['value_tax_exc'] = Tools::convertPrice($base_shipping_without_tax, $currency);
         }
         if ($cart_rule['gift_product']) {
             foreach ($products as &$product) {
                 if ($product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) {
                     $product['is_gift'] = 1;
                     $product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
                     $product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
                     $cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
                     $cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
                 }
             }
         }
     }
     $total_free_shipping = 0;
     if ($free_shipping = Tools::convertPrice(floatval(Configuration::get('PS_SHIPPING_FREE_PRICE')), $currency)) {
         $total_free_shipping = floatval($free_shipping - ($params['cart']->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $params['cart']->getOrderTotal(true, Cart::ONLY_DISCOUNTS)));
         $discounts = $params['cart']->getCartRules(CartRule::FILTER_ACTION_SHIPPING);
         if ($total_free_shipping < 0) {
             $total_free_shipping = 0;
         }
         if (is_array($discounts) && count($discounts)) {
             $total_free_shipping = 0;
         }
     }
     $this->smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas((int) $params['cart']->id), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'discounts' => $cart_rules, 'nb_total_products' => (int) $nbTotalProducts, 'shipping_cost' => $shipping_cost, 'shipping_cost_float' => $shipping_cost_float, 'show_wrapping' => $wrappingCost > 0 ? true : false, 'show_tax' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING), $currency), 'total' => Tools::displayPrice($totalToPay, $currency), 'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order', 'ajax_allowed' => (int) Configuration::get('PS_BLOCK_CART_AJAX') == 1 ? true : false, 'static_token' => Tools::getToken(false), 'free_shipping' => $total_free_shipping));
     if (count($errors)) {
         $this->smarty->assign('errors', $errors);
     }
     if (isset($this->context->cookie->ajax_blockcart_display)) {
         $this->smarty->assign('colapseExpandStatus', $this->context->cookie->ajax_blockcart_display);
     }
 }
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 6844 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/WishList.php';
$error = '';
// Instance of module class for translations
$module = new BlockWishList();
$token = Tools::getValue('token');
$id_product = (int) Tools::getValue('id_product');
$id_product_attribute = (int) Tools::getValue('id_product_attribute');
if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('static_token'))) {
    $error = $module->l('Invalid token', 'buywishlistproduct');
}
if (!strlen($error) && empty($token) === false && empty($id_product) === false) {
    $wishlist = WishList::getByToken($token);
    if ($wishlist !== false) {
        WishList::addBoughtProduct($wishlist['id_wishlist'], $id_product, $id_product_attribute, $cart->id, 1);
    }
} else {
    $error = $module->l('You must log in', 'buywishlistproduct');
}
if (empty($error) === false) {
    echo $error;
}
?>
carrito";
}

function enviaCarro(idProduct,conexion){

	var ajaxObject = seConnect(conexion);
	var url="<?php 
echo __PS_BASE_URI__;
?>
carro-de-la-compra";
	var params = "";
	if (ajaxObject){	
		try{
		   params+="?token=<?php 
echo Tools::getToken(false);
?>
";
		   params+="&id_product="+idProduct;
		   params+="&add=1";
		   params+="&id_product_attribute=";
		   params+="Submit=AƱadir+al+carrito";
		   
		   ajaxObject.open("GET", url+params, true);
		   ajaxObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		   ajaxObject.setRequestHeader("Content-length", params.length);
		   ajaxObject.setRequestHeader("Connection", "close");            
		   ajaxObject.onreadystatechange = respuestaEnviaCarro(conexion);
		   ajaxObject.send(null);                 
		}catch(err){        
			alert("Problema enviando al carro");
Example #25
0
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../header.php';
include_once dirname(__FILE__) . '/WishList.php';
$context = Context::getContext();
$errors = array();
Tools::displayFileAsDeprecated();
// Instance of module class for translations
$module = new BlockWishList();
if ($context->customer->isLogged()) {
    $add = Tools::getIsset('add');
    $add = empty($add) === false ? 1 : 0;
    $delete = Tools::getIsset('deleted');
    $delete = empty($delete) === false ? 1 : 0;
    $id_wishlist = Tools::getValue('id_wishlist');
    if (Tools::isSubmit('submitWishlist')) {
        if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) {
            $errors[] = $module->l('Invalid token', 'mywishlist');
        }
        if (!sizeof($errors)) {
            $name = Tools::getValue('name');
            if (empty($name)) {
                $errors[] = $module->l('You must specify a name.', 'mywishlist');
            }
            if (WishList::isExistsByNameForUser($name)) {
                $errors[] = $module->l('This name is already used by another list.', 'mywishlist');
            }
            if (!sizeof($errors)) {
                $wishlist = new WishList();
                $wishlist->name = $name;
                $wishlist->id_customer = (int) $context->customer->id;
                $wishlist->id_shop = $context->shop->id;
Example #26
0
         }
     }
 }
 if (!$category) {
     $category = new Category($product->id_category_default, intval($cookie->id_lang));
 }
 if (isset($category) and Validate::isLoadedObject($category)) {
     $smarty->assign(array('category' => $category, 'subCategories' => $category->getSubCategories(intval($cookie->id_lang), true), 'id_category_current' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name))));
 }
 $smarty->assign(array('return_link' => (isset($category->id) and $category->id) ? Tools::safeOutput($link->getCategoryLink($category)) : 'javascript: history.back();', 'path' => (isset($category->id) and $category->id) ? Tools::getFullPath(intval($category->id), $product->name) : Tools::getFullPath(intval($product->id_category_default), $product->name)));
 $lang = Configuration::get('PS_LANG_DEFAULT');
 if (Pack::isPack(intval($product->id), intval($lang)) and !Pack::isInStock(intval($product->id), intval($lang))) {
     $product->quantity = 0;
 }
 /* /Quantity discount management */
 $smarty->assign(array('quantity_discounts' => QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()), 'product' => $product, 'homeSize' => Image::getSize('home'), 'jqZoomEnabled' => $jqZoomEnabled, 'product_manufacturer' => new Manufacturer(intval($product->id_manufacturer)), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => floatval($productPriceWithoutEcoTax), 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $product->isAvailableWhenOutOfStock(intval($product->out_of_stock)), 'last_qties' => intval($configs['PS_LAST_QTIES']), 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, 'col_img_dir' => _PS_COL_IMG_DIR_, 'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
 $images = $product->getImages(intval($cookie->id_lang));
 $productImages = array();
 foreach ($images as $k => $image) {
     if ($image['cover']) {
         $smarty->assign('mainImage', $images[0]);
         $cover = $image;
         $cover['id_image'] = intval($product->id) . '-' . $cover['id_image'];
         $cover['id_image_only'] = intval($image['id_image']);
     }
     $productImages[intval($image['id_image'])] = $image;
 }
 if (!isset($cover)) {
     $cover = array('id_image' => Language::getIsoById($cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
 }
 $size = Image::getSize('large');
Example #27
0
<?php

// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
require_once dirname(__FILE__) . '/init.php';
/* CSS */
$css_files[_THEME_CSS_DIR_ . 'global.css'] = 'all';
/* Hooks are volontary out the initialize array (need those variables already assigned) */
$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'), 'HOOK_TOP' => Module::hookExec('top'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => intval(Tools::getValue('content_only'))));
if (isset($css_files) and !empty($css_files)) {
    $smarty->assign('css_files', $css_files);
}
if (isset($js_files) and !empty($js_files)) {
    $smarty->assign('js_files', $js_files);
}
/* Display a maintenance page if shop is closed */
if (isset($maintenance) and (!isset($_SERVER['REMOTE_ADDR']) or $_SERVER['REMOTE_ADDR'] != Configuration::get('PS_MAINTENANCE_IP'))) {
    header('HTTP/1.1 503 temporarily overloaded');
    $smarty->display(_PS_THEME_DIR_ . 'maintenance.tpl');
    exit;
}
$smarty->caching = 0;
$smarty->display(_PS_THEME_DIR_ . 'header.tpl');
 public function displayHeader($display = true)
 {
     if (!$this->instant_search && !$this->ajax_search) {
         parent::displayHeader();
     } else {
         $this->context->smarty->assign('static_token', Tools::getToken(false));
     }
 }
Example #29
0
 /**
  * Check if token is valid
  *
  * @since 1.5.0
  * @return bool
  */
 public function isTokenValid()
 {
     if (!Configuration::get('PS_TOKEN_ENABLE')) {
         return true;
     }
     return strcasecmp(Tools::getToken(false), Tools::getValue('token')) == 0;
 }
Example #30
0
 public function hookRightColumn($params)
 {
     global $smarty;
     global $errors;
     if (Configuration::get('PS_BLOCK_WISHLIST_ACTIVATED') == 0) {
         return null;
     }
     require_once dirname(__FILE__) . '/WishList.php';
     if ($params['cookie']->isLogged()) {
         $wishlists = Wishlist::getByIdCustomer($params['cookie']->id_customer);
         if (empty($params['cookie']->id_wishlist) === true || WishList::exists($params['cookie']->id_wishlist, $params['cookie']->id_customer) === false) {
             if (!sizeof($wishlists)) {
                 $id_wishlist = false;
             } else {
                 $id_wishlist = intval($wishlists[0]['id_wishlist']);
                 $params['cookie']->id_wishlist = intval($id_wishlist);
             }
         } else {
             $id_wishlist = $params['cookie']->id_wishlist;
         }
         $smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $params['cookie']->id_customer, $params['cookie']->id_lang, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false)));
     } else {
         $smarty->assign(array('products' => false, 'wishlists' => false));
     }
     return $this->display(__FILE__, 'blockwishlist.tpl');
 }