Example #1
0
 public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6)
 {
     $sql_groups_where = '';
     $sql_groups_join = '';
     if (Group::isFeatureActive()) {
         $sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)';
         $groups = FrontController::getCurrentCustomerGroups();
         $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id);
     }
     $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
     SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
     FROM `' . _DB_PREFIX_ . 'category` c
     ' . Shop::addSqlAssociation('category', 'c') . '
     LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` 
 		AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ')
     ' . $sql_groups_join . '
     WHERE `id_parent` = ' . (int) $id_category . '
     ' . ($active ? 'AND `active` = 1' : '') . '
     ' . $sql_groups_where . '
     GROUP BY c.`id_category`
     ORDER BY `level_depth` ASC, category_shop.`position` ASC
     LIMIT ' . (int) $p . ', ' . (int) $n);
     foreach ($result as &$row) {
         $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default';
         $row['legend'] = 'no picture';
     }
     return $result;
 }
Example #2
0
 public static function getReduction($id_customer = null)
 {
     if (!isset(self::$cache_reduction['customer'][(int) $id_customer])) {
         $id_group = $id_customer ? Customer::getDefaultGroupId((int) $id_customer) : (int) Group::getCurrent()->id;
         self::$cache_reduction['customer'][(int) $id_customer] = Group::getReductionByIdGroup($id_group);
     }
     return self::$cache_reduction['customer'][(int) $id_customer];
 }
 public function __construct(stdClass $datas)
 {
     $this->datas = $datas;
     $this->context = Context::getContext();
     $this->module = Module::getInstanceByName('powatag');
     $this->initLang();
     $id_group = Group::getCurrent()->id;
     $this->display_taxes = Group::getPriceDisplayMethod($id_group) == PS_TAX_EXC ? false : true;
 }
Example #4
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();
     $base_shipping = $params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING);
     $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($params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING), $currency);
             $cart_rule['value_tax_exc'] = Tools::convertPrice($params['cart']->getOrderTotal(false, Cart::ONLY_SHIPPING), $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_);
                 }
             }
         }
     }
     $this->smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas((int) $params['cart']->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _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)));
     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);
     }
 }
 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     die('coucou');
     $id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
     $id_group = (int) Group::getCurrent()->id;
     $id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
     $group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
     if ($group_reduction === false) {
         $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
     $this->context->smarty->assign('tax_rate', $tax);
     $product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
     if (Product::$_taxCalculationMethod == PS_TAX_INC) {
         $product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
     if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
         $ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $id_currency = (int) $this->context->cookie->id_currency;
     $id_product = (int) $this->product->id;
     $id_shop = $this->context->shop->id;
     $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount['id_product_attribute']) {
             $combination = new Combination((int) $quantity_discount['id_product_attribute']);
             $attributes = $combination->getAttributesName((int) $this->context->language->id);
             foreach ($attributes as $attribute) {
                 $quantity_discount['attributes'] = $attribute['name'] . ' - ';
             }
             $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
         }
         if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
             $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
     $address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
 }
Example #6
0
    public static function checkAccessStatic($id_product, $id_customer)
    {
        if (!Group::isFeatureActive()) {
            return true;
        }
        $cache_id = 'Product::checkAccess_' . (int) $id_product . '-' . (int) $id_customer . (!$id_customer ? '-' . (int) Group::getCurrent()->id : '');
        if (!Cache::isStored($cache_id)) {
            if (!$id_customer) {
                $result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT ctg.`id_group`
				FROM `' . _DB_PREFIX_ . 'category_product` cp
				INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
				WHERE cp.`id_product` = ' . (int) $id_product . ' AND ctg.`id_group` = ' . (int) Group::getCurrent()->id);
            } else {
                $result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT cg.`id_group`
				FROM `' . _DB_PREFIX_ . 'category_product` cp
				INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
				INNER JOIN `' . _DB_PREFIX_ . 'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
				WHERE cp.`id_product` = ' . (int) $id_product . ' AND cg.`id_customer` = ' . (int) $id_customer);
            }
            Cache::store($cache_id, $result);
            return $result;
        }
        return Cache::retrieve($cache_id);
    }
Example #7
0
 protected function getCacheId($name = null)
 {
     $cache_array = array();
     $cache_array[] = $name !== null ? $name : $this->name;
     if (Configuration::get('PS_SSL_ENABLED')) {
         $cache_array[] = (int) Tools::usingSecureMode();
     }
     if (Shop::isFeatureActive()) {
         $cache_array[] = (int) $this->context->shop->id;
     }
     $cache_array[] = (int) Group::getCurrent()->id;
     if (Language::isMultiLanguageActivated()) {
         $cache_array[] = (int) $this->context->language->id;
     }
     if (Currency::isMultiCurrencyActivated()) {
         $cache_array[] = (int) $this->context->currency->id;
     }
     $cache_array[] = (int) $this->context->country->id;
     return implode('|', $cache_array);
 }
Example #8
0
    /**
     * checkAccess return true if id_customer is in a group allowed to see this category.
     *
     * @param mixed $id_customer
     * @access public
     * @return boolean true if access allowed for customer $id_customer
     */
    public function checkAccess($id_customer)
    {
        if (!$id_customer) {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
				SELECT ctg.`id_group`
				FROM ' . _DB_PREFIX_ . 'category_group ctg
				WHERE ctg.`id_category` = ' . (int) $this->id . ' AND ctg.`id_group` = ' . (int) Group::getCurrent()->id . '
			');
        } else {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
				SELECT ctg.`id_group`
				FROM ' . _DB_PREFIX_ . 'category_group ctg
				INNER JOIN ' . _DB_PREFIX_ . 'customer_group cg on (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = ' . (int) $id_customer . ')
				WHERE ctg.`id_category` = ' . (int) $this->id);
        }
        if ($result && isset($result['id_group']) && $result['id_group']) {
            return true;
        }
        return false;
    }
Example #9
0
 protected function getCacheId($name = null, $hook = '')
 {
     $cache_array = array($name !== null ? $name : $this->name, $hook, date('Ymd'), (int) Tools::usingSecureMode(), (int) $this->context->shop->id_shop_url, (int) Group::getCurrent()->id, (int) $this->context->language->id, (int) $this->context->currency->id, (int) $this->context->country->id, !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443);
     return implode('|', $cache_array);
 }
Example #10
0
 public function renderView()
 {
     if (!($cart = $this->loadObject(true))) {
         return;
     }
     $customer = new Customer($cart->id_customer);
     $currency = new Currency($cart->id_currency);
     $this->context->cart = $cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     $this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->id);
     $products = $cart->getProducts();
     $customized_datas = Product::getAllCustomizedDatas((int) $cart->id);
     Product::addCustomizationPrice($products, $customized_datas);
     $summary = $cart->getSummaryDetails();
     /* Display order information */
     $id_order = (int) Order::getOrderByCartId($cart->id);
     $order = new Order($id_order);
     if (Validate::isLoadedObject($order)) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $id_shop = (int) $order->id_shop;
     } else {
         $id_shop = (int) $cart->id_shop;
         $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id);
     }
     if ($tax_calculation_method == PS_TAX_EXC) {
         $total_products = $summary['total_products'];
         $total_discounts = $summary['total_discounts_tax_exc'];
         $total_wrapping = $summary['total_wrapping_tax_exc'];
         $total_price = $summary['total_price_without_tax'];
         $total_shipping = $summary['total_shipping_tax_exc'];
     } else {
         $total_products = $summary['total_products_wt'];
         $total_discounts = $summary['total_discounts'];
         $total_wrapping = $summary['total_wrapping'];
         $total_price = $summary['total_price'];
         $total_shipping = $summary['total_shipping'];
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == PS_TAX_EXC) {
             $product['product_price'] = $product['price'];
             $product['product_total'] = $product['total'];
         } else {
             $product['product_price'] = $product['price_wt'];
             $product['product_total'] = $product['total_wt'];
         }
         $image = array();
         if (isset($product['id_product_attribute']) && (int) $product['id_product_attribute']) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['id_product_attribute']);
         }
         if (!isset($image['id_image'])) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['id_product'] . ' AND cover = 1');
         }
         $product_obj = new Product($product['id_product']);
         $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int) $id_shop);
         $image_product = new Image($image['id_image']);
         $product['image'] = isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $image_product->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--';
     }
     $helper = new HelperKpi();
     $helper->id = 'box-kpi-cart';
     $helper->icon = 'icon-shopping-cart';
     $helper->color = 'color1';
     $helper->title = $this->l('Total Cart', null, null, false);
     $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
     $helper->value = Tools::displayPrice($total_price, $currency);
     $kpi = $helper->generate();
     $this->tpl_view_vars = array('kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), 'order' => $order, 'cart' => $cart, 'currency' => $currency, 'customer' => $customer, 'customer_stats' => $customer->getStats(), 'total_products' => $total_products, 'total_discounts' => $total_discounts, 'total_wrapping' => $total_wrapping, 'total_price' => $total_price, 'total_shipping' => $total_shipping, 'customized_datas' => $customized_datas);
     return parent::renderView();
 }
Example #11
0
    public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null, $only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null, $id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null, $use_customer_price = true)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        $cur_cart = $context->cart;
        if ($divisor !== null) {
            Tools::displayParameterAsDeprecated('divisor');
        }
        if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product)) {
            die(Tools::displayError());
        }
        $id_group = null;
        if ($id_customer) {
            $id_group = Customer::getDefaultGroupId((int) $id_customer);
        }
        if (!$id_group) {
            $id_group = (int) Group::getCurrent()->id;
        }
        if (!is_object($cur_cart) || Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart) {
            /*
             * When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
             * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
             * When called from the back office, cart ID can be inexistant
             */
            if (!$id_cart && !isset($context->employee)) {
                die(Tools::displayError());
            }
            $cur_cart = new Cart($id_cart);
            if (!Validate::isLoadedObject($context->cart)) {
                $context->cart = $cur_cart;
            }
        }
        $qty = $quantity;
        if (is_array($quantity)) {
            $quantity = PP::resolveQty($qty[0], $qty[1]);
        }
        $cart_quantity = 0;
        if ((int) $id_cart) {
            $cache_id = 'Product::getPriceStatic_' . (int) $id_product . '-' . (int) $id_cart;
            if (!Cache::isStored($cache_id) || ($cart_quantity = Cache::retrieve($cache_id) != (double) $quantity)) {
                $sql = 'SELECT SUM(' . PP::sqlQty('quantity') . ')
				FROM `' . _DB_PREFIX_ . 'cart_product`
				WHERE `id_product` = ' . (int) $id_product . '
				AND `id_cart` = ' . (int) $id_cart;
                $cart_quantity = (double) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                Cache::store($cache_id, $cart_quantity);
            }
            $cart_quantity = Cache::retrieve($cache_id);
        }
        $id_currency = (int) Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
        $id_country = (int) $context->country->id;
        $id_state = 0;
        $zipcode = 0;
        if (!$id_address && Validate::isLoadedObject($cur_cart)) {
            $id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
        }
        if ($id_address) {
            $address_infos = Address::getCountryAndState($id_address);
            if ($address_infos['id_country']) {
                $id_country = (int) $address_infos['id_country'];
                $id_state = (int) $address_infos['id_state'];
                $zipcode = $address_infos['postcode'];
            }
        } elseif (isset($context->customer->geoloc_id_country)) {
            $id_country = (int) $context->customer->geoloc_id_country;
            $id_state = (int) $context->customer->id_state;
            $zipcode = $context->customer->postcode;
        }
        if (Tax::excludeTaxeOption()) {
            $usetax = false;
        }
        if ($usetax != false && !empty($address_infos['vat_number']) && $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') && Configuration::get('VATNUMBER_MANAGEMENT')) {
            $usetax = false;
        }
        if (is_null($id_customer) && Validate::isLoadedObject($context->customer)) {
            $id_customer = $context->customer->id;
        }
        return Product::priceCalculation($context->shop->id, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $qty, $usetax, $decimals, $only_reduc, $usereduc, $with_ecotax, $specific_price_output, $use_group_reduction, $id_customer, $use_customer_price, $id_cart, $cart_quantity);
    }
Example #12
0
    /**
     * Returns module content for left column
     */
    public function hookProductFooter($params)
    {
        $cache_id = 'crossselling_mod|productfooter|' . (int) $params['product']->id;
        if (!$this->isCached('crossselling_mod.tpl', $this->getCacheId($cache_id))) {
            $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT o.id_order
			FROM ' . _DB_PREFIX_ . 'orders o
			LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
			WHERE o.valid = 1 AND od.product_id = ' . (int) $params['product']->id);
            if (count($orders)) {
                $list = '';
                foreach ($orders as $order) {
                    $list .= (int) $order['id_order'] . ',';
                }
                $list = rtrim($list, ',');
                if (Group::isFeatureActive()) {
                    $sql_groups_join = '
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = product_shop.id_category_default AND cp.id_product = product_shop.id_product)
					LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
                    $groups = FrontController::getCurrentCustomerGroups();
                    $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '=' . (int) Group::getCurrent()->id);
                }
                $order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, product_shop.id_category_default, p.available_for_order, p.customizable, cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
					FROM ' . _DB_PREFIX_ . 'order_detail od
					LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
					' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
					ON (p.`id_product` = pa.`id_product`)
					' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
					' . Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) : Product::sqlStock('p', 'product', false, $this->context->shop)) . '
					LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
					LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
					LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
					' . (Group::isFeatureActive() ? $sql_groups_join : '') . '
					WHERE od.id_order IN (' . $list . ')
					AND pl.id_lang = ' . (int) $this->context->language->id . '
					AND cl.id_lang = ' . (int) $this->context->language->id . '
					AND od.product_id != ' . (int) $params['product']->id . '
					AND i.cover = 1
					AND product_shop.active = 1
					' . (Group::isFeatureActive() ? $sql_groups_where : '') . '
					ORDER BY RAND()
					LIMIT ' . (int) Configuration::get('CROSSSELLING_NBR_M'));
                $tax_calc = Product::getTaxCalculationMethod();
                foreach ($order_products as &$order_product) {
                    $order_product['id_product'] = (int) $order_product['product_id'];
                    $order_product['image'] = $this->context->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('home'));
                    $order_product['link'] = $this->context->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
                    if ($tax_calc == 0 || $tax_calc == 2) {
                        $order_product['price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
                    } elseif ($tax_calc == 1) {
                        $order_product['price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
                    }
                    $order_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int) $order_product['out_of_stock']);
                }
                $order_products = Product::getProductsProperties((int) $this->context->language->id, $order_products);
                $this->smarty->assign(array('order' => false, 'orderProducts' => $order_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'middlePosition_crossselling' => round(count($order_products) / 2, 0), 'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE_M')));
            }
        }
        return $this->display(__FILE__, 'crossselling_mod.tpl', $this->getCacheId($cache_id));
    }
Example #13
0
 protected function getCacheId($name = null)
 {
     $cache_array = array($name !== null ? $name : $this->name, (int) Tools::usingSecureMode(), (int) $this->context->shop->id, (int) Group::getCurrent()->id, (int) $this->context->language->id, (int) $this->context->currency->id, (int) $this->context->country->id);
     return implode('|', $cache_array);
 }
Example #14
0
 public function getTemplateVarProduct()
 {
     $productSettings = $this->getProductPresentationSettings();
     $product = $this->objectPresenter->present($this->product);
     $product['id_product'] = (int) $this->product->id;
     $product['out_of_stock'] = (int) $this->product->out_of_stock;
     $product['new'] = (int) $this->product->new;
     $product['id_product_attribute'] = (int) Tools::getValue('id_product_attribute');
     $product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
     $product['quantity_wanted'] = $this->getRequiredQuantity($product);
     $product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
     $product_full = $this->addProductCustomizationData($product_full);
     $product_full['show_quantities'] = (bool) (Configuration::get('PS_DISPLAY_QTIES') && Configuration::get('PS_STOCK_MANAGEMENT') && $this->product->quantity > 0 && $this->product->available_for_order && !Configuration::isCatalogMode());
     $product_full['quantity_label'] = $this->product->quantity > 1 ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
     $product_full['quantity_discounts'] = $this->quantity_discounts;
     if ($product_full['unit_price_ratio'] > 0) {
         $unitPrice = $productSettings->include_taxes ? $product_full['price'] : $product_full['price_tax_exc'];
         $product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
     }
     $group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
     if ($group_reduction === false) {
         $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
     }
     $product_full['customer_group_discount'] = $group_reduction;
     $presenter = $this->getProductPresenter();
     return $presenter->present($productSettings, $product_full, $this->context->language);
 }
Example #15
0
 protected function getCacheId($id_product = null, $hook = '')
 {
     $cache_array = array($id_product, $hook, date('Ymd'), (int) Tools::usingSecureMode(), (int) $this->context->shop->id, (int) Group::getCurrent()->id, (int) $this->context->language->id, (int) $this->context->currency->id, (int) $this->context->country->id);
     return implode('|', $cache_array);
 }
 public function initContent()
 {
     if (!$this->ajax) {
         parent::initContent();
     }
     //  parent::initContent();
     $this->setTemplate(_PS_THEME_DIR_ . 'category.tpl');
     if (!$this->customer_access) {
         return;
     }
     if (isset($this->context->cookie->id_compare)) {
         $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) $this->context->cookie->id_compare));
     }
     $this->productSort();
     // Product sort must be called before assignProductList()
     $this->assignScenes();
     $this->assignSubcategories();
     $this->assignProductList();
     $products = isset($this->cat_products) && $this->cat_products ? $this->cat_products : null;
     $combinations = array();
     if ($products !== NULL) {
         foreach ($products as &$pro) {
             $product_obj = new Product($pro['id_product'], $this->context->language->id);
             $pro['groups'] = $product_obj->getProductCombinationsGroups($pro['id_product']);
             $combinations[$pro['id_product']] = $product_obj->getProductAttributeCombinations($pro['id_product']);
             $id_group = (int) Group::getCurrent()->id;
             $group_reduction = GroupReduction::getValueForProduct($pro['id_product'], $id_group);
             if ($group_reduction === false) {
                 $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
             }
             $pro['group_reduction'] = $group_reduction;
             $address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             $pro['no_tax'] = Tax::excludeTaxeOption() || !$product_obj->getTaxesRate($address);
             $pro['customer_group_without_tax'] = Group::getPriceDisplayMethod($this->context->customer->id_default_group);
             $tax = (double) $product_obj->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
             $pro['tax_rate'] = $tax;
             $pro['unit_price_ratio'] = $product_obj->unit_price_ratio;
             $ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             $pro['ecotaxTax_rate'] = $ecotax_rate;
         }
     }
     $this->context->smarty->assign(array('category' => $this->category, 'description_short' => Tools::truncateString($this->category->description, 350), 'products' => $products, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'body_classes' => array($this->php_self . '-' . $this->category->id, $this->php_self . '-' . $this->category->link_rewrite), 'combinations' => $combinations));
 }
Example #17
0
 /**
  * @param array $products_id an array of product ids
  * @return array
  */
 protected function getOrderProducts(array $products_id)
 {
     $q_orders = 'SELECT o.id_order
     FROM ' . _DB_PREFIX_ . 'orders o
     LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
     WHERE o.valid = 1 AND od.product_id IN (' . implode(',', $products_id) . ')';
     $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($q_orders);
     $final_products_list = array();
     if (count($orders) > 0) {
         $list = '';
         foreach ($orders as $order) {
             $list .= (int) $order['id_order'] . ',';
         }
         $list = rtrim($list, ',');
         $list_product_ids = join(',', $products_id);
         if (Group::isFeatureActive()) {
             $sql_groups_join = '
             LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = product_shop.id_category_default
                 AND cp.id_product = product_shop.id_product)
             LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
             $groups = FrontController::getCurrentCustomerGroups();
             $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '=' . (int) Group::getCurrent()->id);
         }
         $order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
             SELECT DISTINCT od.product_id, pl.name, pl.description_short, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
                 cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
             FROM ' . _DB_PREFIX_ . 'order_detail od
             LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
             ' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
             ON (p.`id_product` = pa.`id_product`)
             ' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
             ' . Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) : Product::sqlStock('p', 'product', false, $this->context->shop)) . '
             LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
             LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
             LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
             ' . (Group::isFeatureActive() ? $sql_groups_join : '') . '
             WHERE od.id_order IN (' . $list . ')
             AND pl.id_lang = ' . (int) $this->context->language->id . '
             AND cl.id_lang = ' . (int) $this->context->language->id . '
             AND od.product_id NOT IN (' . $list_product_ids . ')
             AND i.cover = 1
             AND product_shop.active = 1
             ' . (Group::isFeatureActive() ? $sql_groups_where : '') . '
             ORDER BY RAND()
             LIMIT ' . (int) Configuration::get('CROSSSELLING_NBR'));
         $tax_calc = Product::getTaxCalculationMethod();
         foreach ($order_products as &$order_product) {
             $order_product['id_product'] = (int) $order_product['product_id'];
             $order_product['image'] = $this->context->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('home'));
             $order_product['link'] = $this->context->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
             if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && ($tax_calc == 0 || $tax_calc == 2)) {
                 $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
             } elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && $tax_calc == 1) {
                 $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
             }
             $order_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int) $order_product['out_of_stock']);
             if (!isset($final_products_list[$order_product['product_id'] . '-' . $order_product['id_image']])) {
                 $final_products_list[$order_product['product_id'] . '-' . $order_product['id_image']] = $order_product;
             }
         }
     }
     return $final_products_list;
 }
Example #18
0
 /**
  *
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'adyen') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // get the selected currency
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     // validate order
     // $payment_method name must be the same as module name otherwise successurl won't show
     $this->module->validateOrder($cart->id, Configuration::get('ADYEN_NEW_STATUS'), $total, 'Adyen', null, array(), (int) $currency->id, false, $customer->secure_key);
     Logger::addLog('Adyen module: order is validated for id_order ' . $cart->id);
     // go to form adyen post values (submitted automatically)
     $config = Configuration::getMultiple(array('ADYEN_MERCHANT_ACCOUNT', 'ADYEN_MODE', 'ADYEN_SKIN_CODE', 'ADYEN_HMAC_TEST', 'ADYEN_HMAC_LIVE', 'ADYEN_NOTI_USERNAME', 'ADYEN_NOTI_PASSWORD', 'ADYEN_DAYS_DELIVERY', 'PS_SSL_ENABLED', 'ADYEN_COUNTRY_CODE_ISO', 'ADYEN_LANGUAGE_LOCALE'));
     $customer = new Customer((int) $cart->id_customer);
     $address = new Address((int) $cart->id_address_invoice);
     $country = new Country((int) $address->id_country);
     $language = Language::getIsoById((int) $cart->id_lang);
     if (!Validate::isLoadedObject($address) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($currency)) {
         Logger::addLog('Adyen module: invalid address, customer, or currency for id_order ' . $cart->id, 4);
         return $this->module->l('Adyen error: (invalid address, customer, or currency)');
     }
     $merchant_account = (string) $config['ADYEN_MERCHANT_ACCOUNT'];
     $skin_code = (string) $config['ADYEN_SKIN_CODE'];
     $currency_code = (string) $currency->iso_code;
     $shopper_email = (string) $customer->email;
     $merchant_reference = (int) $this->module->currentOrder;
     // set when order is validated
     $payment_amount = number_format($cart->getOrderTotal(true, 3), 2, '', '');
     $shopper_reference = (string) $customer->secure_key;
     if ($config['ADYEN_COUNTRY_CODE_ISO'] != '') {
         $country_code = (string) $config['ADYEN_COUNTRY_CODE_ISO'];
     } else {
         $country_code = (string) $country->iso_code;
     }
     // Locale (language) to present to shopper (e.g. en_US, nl, fr, fr_BE)
     if ($config['ADYEN_LANGUAGE_LOCALE'] != '') {
         $shopper_locale = (string) $config['ADYEN_LANGUAGE_LOCALE'];
     } else {
         $shopper_locale = (string) $language;
     }
     $recurring_contract = 'ONECLICK';
     $ship_before_date = date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), date('j') + (isset($config['ADYEN_DAYS_DELIVERY']) ? $config['ADYEN_DAYS_DELIVERY'] : 5), date('Y')));
     // example: ship in 5 days
     $session_validity = date(DATE_ATOM, mktime(date('H') + 1, date('i'), date('s'), date('m'), date('j'), date('Y')));
     // presentation of the shopping basket.
     $tax_calculation_method = Group::getPriceDisplayMethod((int) Group::getCurrent()->id);
     $use_tax = !($tax_calculation_method == PS_TAX_EXC);
     $shipping_cost = Tools::displayPrice($cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING), $currency);
     $prod_details = sprintf('Shipment cost: %s <br />', $shipping_cost);
     $prod_details .= 'Order rows: <br />';
     // get order items
     foreach ($cart->getProducts() as $product) {
         $name = $product['name'];
         $qty_ordered = (int) $product['cart_quantity'];
         $row_total = Tools::ps_round($product['total_wt'], 2);
         $prod_details .= sprintf('%s ( Qty: %s ) ( Price: %s %s ) <br />', $name, $qty_ordered, $row_total, $currency_code);
     }
     $order_data = base64_encode(gzencode($prod_details));
     // for elv and cc can be mutliple values seperate by comma(,)
     $blocked_methods = '';
     $hmac_data = $payment_amount . $currency_code . $ship_before_date . $merchant_reference . $skin_code . $merchant_account . $session_validity . $shopper_email . $shopper_reference . $recurring_contract . $blocked_methods;
     $merchant_sig = base64_encode(pack('H*', $this->module->getHmacsha1($this->module->getHmac(), $hmac_data)));
     $brand_code = '';
     $ideal_issuer_id = '';
     $skip_selection = '';
     if (Tools::getValue('payment_type') != '') {
         $brand_code = (string) Tools::getValue('payment_type');
     }
     if (Tools::getValue('ideal_type') != '') {
         $ideal_issuer_id = (int) Tools::getValue('ideal_type');
         $skip_selection = 'true';
     }
     $this->context->smarty->assign(array('merchantAccount' => $merchant_account, 'skinCode' => $skin_code, 'currencyCode' => $currency_code, 'shopperEmail' => $shopper_email, 'merchantReference' => $merchant_reference, 'paymentAmount' => $payment_amount, 'shopperReference' => $shopper_reference, 'shipBeforeDate' => $ship_before_date, 'sessionValidity' => $session_validity, 'shopperLocale' => $shopper_locale, 'countryCode' => $country_code, 'orderData' => $order_data, 'recurringContract' => $recurring_contract, 'merchantSig' => $merchant_sig, 'adyenUrl' => $this->getAdyenUrl($brand_code, $ideal_issuer_id), 'resURL' => ($config['PS_SSL_ENABLED'] ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'index.php?controller=order-confirmation&key=' . $customer->secure_key . '&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder, 'brandCode' => $brand_code, 'skipSelection' => $skip_selection, 'idealIssuerId' => $ideal_issuer_id));
 }
Example #19
0
 /**
  * use this code
  * Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1');
  * where you want to have RANDOM cache
  */
 protected function getCacheId($name = null)
 {
     $cache_array = array();
     $cache_array[] = $name !== null ? $name : $this->name;
     if (isset($this->cache_param) && $this->cache_param) {
         if (isset($this->cache_param['controller']) && $this->cache_param['controller']) {
             $cache_array[] = $this->cache_param['controller'];
         }
         if (isset($this->cache_param['id']) && $this->cache_param['id']) {
             $cache_array[] = $this->cache_param['id'];
         }
         if (isset($this->cache_param['hook']) && $this->cache_param['hook']) {
             $cache_array[] = $this->cache_param['hook'];
         }
         // save to next time
         if (Configuration::get('LEO_CURRENT_RANDOM_CACHE') == 1) {
             $random_cache = Configuration::get('LEO_RANDOM_CACHE');
             if (!$random_cache) {
                 # validate module
                 $random_cache = new stdClass();
             } else {
                 # validate module
                 $random_cache = Tools::jsonDecode($random_cache);
             }
             $key = implode('|', $cache_array);
             $random_cache->{$key} = date('Ymd');
             $leo_random_cache = Tools::jsonEncode($random_cache);
             Configuration::updateValue('LEO_RANDOM_CACHE', $leo_random_cache);
         }
         // Check RANDOM PRODUCT
         if ($random_cache = Configuration::get('LEO_RANDOM_CACHE')) {
             $key = implode('|', $cache_array);
             $value = date('Ymd');
             $random_cache = Tools::jsonDecode($random_cache);
             if (isset($random_cache->{$key}) && $random_cache->{$key} == $value) {
                 // cache in one day
                 $random = date('Ymd') . '_' . rand(1, LeomanagewidgetsHelper::NUMBER_CACHE_FILE);
                 $cache_array[] = 'random_' . $random;
             }
         }
     }
     if (Configuration::get('PS_SSL_ENABLED')) {
         $cache_array[] = (int) Tools::usingSecureMode();
     }
     if (Shop::isFeatureActive()) {
         $cache_array[] = (int) $this->context->shop->id;
     }
     if (Group::isFeatureActive()) {
         $cache_array[] = (int) Group::getCurrent()->id;
     }
     if (Language::isMultiLanguageActivated()) {
         $cache_array[] = (int) $this->context->language->id;
     }
     if (Currency::isMultiCurrencyActivated()) {
         $cache_array[] = (int) $this->context->currency->id;
     }
     $cache_array[] = (int) $this->context->country->id;
     return implode('|', $cache_array);
 }
Example #20
0
    public function getProducts($ids)
    {
        $product_ids = join(',', $ids);
        if (Group::isFeatureActive()) {
            $sql_groups_join = '
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = product_shop.id_category_default
						AND cp.id_product = product_shop.id_product)
					LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
            $groups = FrontController::getCurrentCustomerGroups();
            $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '=' . (int) Group::getCurrent()->id);
        }
        $selected_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
					SELECT DISTINCT p.id_product, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, product_shop.`id_category_default`, 
						cl.link_rewrite category, p.ean13, stock.out_of_stock, p.available_for_order, p.customizable, IFNULL(stock.quantity, 0) as quantity,
						DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
					INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
						DAY)) > 0 AS new
					FROM ' . _DB_PREFIX_ . 'product p
					' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
					ON (p.`id_product` = pa.`id_product`)
					' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
					' . Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) : Product::sqlStock('p', 'product', false, $this->context->shop)) . '
					LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = p.id_product' . Shop::addSqlRestrictionOnLang('pl') . ')
					LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
					LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = p.id_product)
					' . (Group::isFeatureActive() ? $sql_groups_join : '') . '
					WHERE p.id_product IN (' . $product_ids . ')
					AND pl.id_lang = ' . (int) $this->context->language->id . '
					AND cl.id_lang = ' . (int) $this->context->language->id . '
					AND i.cover = 1
					AND product_shop.active = 1
					' . (Group::isFeatureActive() ? $sql_groups_where : '') . ' ORDER BY FIELD(p.id_product, ' . $product_ids . ')');
        $tax_calc = Product::getTaxCalculationMethod();
        $final_products_list = array();
        foreach ($selected_products as &$selected_product) {
            $usetax = false;
            $selected_product['id_product'] = (int) $selected_product['id_product'];
            $selected_product['image'] = $this->context->link->getImageLink($selected_product['link_rewrite'], (int) $selected_product['id_product'] . '-' . (int) $selected_product['id_image'], ImageType::getFormatedName('home'));
            $selected_product['link'] = $this->context->link->getProductLink((int) $selected_product['id_product'], $selected_product['link_rewrite'], $selected_product['category'], $selected_product['ean13']);
            if ($tax_calc == 0 || $tax_calc == 2) {
                $usetax = true;
                $selected_product['displayed_price'] = Product::getPriceStatic((int) $selected_product['id_product'], true, null);
            } elseif ($tax_calc == 1) {
                $selected_product['displayed_price'] = Product::getPriceStatic((int) $selected_product['id_product'], false, null);
            }
            $selected_product['price_without_reduction'] = Product::getPriceStatic((int) $selected_product['id_product'], $usetax, isset($selected_product['id_product_attribute']) && !empty($selected_product['id_product_attribute']) ? (int) $selected_product['id_product_attribute'] : null, 6, null, false, false);
            $selected_product['reduction'] = Product::getPriceStatic((int) $selected_product['id_product'], $usetax, isset($selected_product['id_product_attribute']) && !empty($selected_product['id_product_attribute']) ? (int) $selected_product['id_product_attribute'] : null, 6, null, true, true, 1, true, null, null, null, $specific_prices);
            $selected_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int) $selected_product['out_of_stock']);
            if (!isset($final_products_list[$selected_product['id_product'] . '-' . $selected_product['id_image']])) {
                $final_products_list[$selected_product['id_product'] . '-' . $selected_product['id_image']] = $selected_product;
            }
        }
        return $final_products_list;
    }
Example #21
0
 protected function showPriceFilter()
 {
     return Group::getCurrent()->show_prices;
 }
Example #22
0
 public static function initPricesComputation($id_customer = null)
 {
     if ($id_customer) {
         $customer = new Customer((int) $id_customer);
         if (!Validate::isLoadedObject($customer)) {
             die(Tools::displayError());
         }
         self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group);
         $cur_cart = Context::getContext()->cart;
         $id_address = 0;
         if (Validate::isLoadedObject($cur_cart)) {
             $id_address = (int) $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
         }
         $address_infos = Address::getCountryAndState($id_address);
         if (self::$_taxCalculationMethod != PS_TAX_EXC && !empty($address_infos['vat_number']) && $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') && Configuration::get('VATNUMBER_MANAGEMENT')) {
             self::$_taxCalculationMethod = PS_TAX_EXC;
         }
     } else {
         self::$_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
     }
 }
Example #23
0
 public function setTaxCalculationMethod()
 {
     $this->_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
 }
Example #24
0
    public function checkAccess($id_customer)
    {
        if (!$id_customer) {
            return (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT ctg.`id_group`
			FROM `' . _DB_PREFIX_ . 'category_product` cp
			INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
			WHERE cp.`id_product` = ' . (int) $this->id . ' AND ctg.`id_group` =' . (int) Group::getCurrent()->id);
        } else {
            return (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT cg.`id_group`
			FROM `' . _DB_PREFIX_ . 'category_product` cp
			INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
			INNER JOIN `' . _DB_PREFIX_ . 'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
			WHERE cp.`id_product` = ' . (int) $this->id . ' AND cg.`id_customer` = ' . (int) $id_customer);
        }
    }
Example #25
0
 /**
  * checkAccess return true if id_customer is in a group allowed to see this category.
  *
  * @param mixed $id_customer
  * @access public
  * @return bool true if access allowed for customer $id_customer
  */
 public function checkAccess($id_customer)
 {
     $cache_id = 'Category::checkAccess_' . (int) $this->id . '-' . $id_customer . (!$id_customer ? '-' . (int) Group::getCurrent()->id : '');
     if (!Cache::isStored($cache_id)) {
         if (!$id_customer) {
             $result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
             SELECT ctg.`id_group`
             FROM ' . _DB_PREFIX_ . 'category_group ctg
             WHERE ctg.`id_category` = ' . (int) $this->id . ' AND ctg.`id_group` = ' . (int) Group::getCurrent()->id);
         } else {
             $result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
             SELECT ctg.`id_group`
             FROM ' . _DB_PREFIX_ . 'category_group ctg
             INNER JOIN ' . _DB_PREFIX_ . 'customer_group cg on (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = ' . (int) $id_customer . ')
             WHERE ctg.`id_category` = ' . (int) $this->id);
         }
         Cache::store($cache_id, $result);
         return $result;
     }
     return Cache::retrieve($cache_id);
 }
Example #26
0
 public function __construct($id = null, $id_lang = null)
 {
     parent::__construct($id, $id_lang);
     if ($this->id_customer) {
         if (isset(Context::getContext()->customer) && Context::getContext()->customer->id == $this->id_customer) {
             $customer = Context::getContext()->customer;
         } else {
             $customer = new Customer((int) $this->id_customer);
         }
         if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) {
             $this->secure_key = $customer->secure_key;
             $this->save();
         }
     }
     $this->_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
 }
Example #27
0
 public function __construct($id = null, $id_lang = null)
 {
     parent::__construct($id);
     if (!is_null($id_lang)) {
         $this->id_lang = (int) (Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
     }
     if ($this->id_customer) {
         if (isset(Context::getContext()->customer) && Context::getContext()->customer->id == $this->id_customer) {
             $customer = Context::getContext()->customer;
         } else {
             $customer = new Customer((int) $this->id_customer);
         }
         if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) {
             $this->secure_key = $customer->secure_key;
             $this->save();
         }
     }
     $this->_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
 }
Example #28
0
 public static function initPricesComputation($id_customer = null)
 {
     if ($id_customer) {
         $customer = new Customer((int) $id_customer);
         if (!Validate::isLoadedObject($customer)) {
             die(Tools::displayError());
         }
         self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group);
     } else {
         self::$_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
     }
 }
Example #29
0
 public function init()
 {
     /*
      * Globals are DEPRECATED as of version 1.5.
      * Use the Context to access objects instead.
      * Example: $this->context->cart
      */
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     parent::init();
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = true;
     }
     // For compatibility with globals, DEPRECATED as of version 1.5
     $css_files = $this->css_files;
     $js_files = $this->js_files;
     // If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
     if (Configuration::get('PS_SSL_ENABLED') && $_SERVER['REQUEST_METHOD'] != 'POST' && $this->ssl != Tools::usingSecureMode()) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         if ($this->ssl) {
             header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
         } else {
             header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
         }
         exit;
     }
     if ($this->ajax) {
         $this->display_header = false;
         $this->display_footer = false;
     }
     // if account created with the 2 steps register process, remove 'accoun_created' from cookie
     if (isset($this->context->cookie->account_created)) {
         $this->context->smarty->assign('account_created', 1);
         unset($this->context->cookie->account_created);
     }
     ob_start();
     // Init cookie language
     // @TODO This method must be moved into switchLanguage
     Tools::setCookieLanguage($this->context->cookie);
     $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
     $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     $link = new Link($protocol_link, $protocol_content);
     $this->context->link = $link;
     if ($id_cart = (int) $this->recoverCart()) {
         $this->context->cookie->id_cart = (int) $id_cart;
     }
     if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed)) {
         Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
     }
     /* Theme is missing */
     if (!is_dir(_PS_THEME_DIR_)) {
         throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
     }
     if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
         if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault)) {
             $this->context->country = $newDefault;
         }
     }
     $currency = Tools::setCurrency($this->context->cookie);
     if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
         $this->context->customer->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $this->context->customer->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     /* Cart already exists */
     if ((int) $this->context->cookie->id_cart) {
         $cart = new Cart($this->context->cookie->id_cart);
         if ($cart->OrderExists()) {
             unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
             $this->context->cookie->check_cgv = false;
         } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 && !FrontController::isInWhitelistForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
             unset($this->context->cookie->id_cart, $cart);
         } elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency) {
             if ($this->context->cookie->id_customer) {
                 $cart->id_customer = (int) $this->context->cookie->id_customer;
             }
             $cart->id_lang = (int) $this->context->cookie->id_lang;
             $cart->id_currency = (int) $currency->id;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || !$cart->id) {
         $cart = new Cart();
         $cart->id_lang = (int) $this->context->cookie->id_lang;
         $cart->id_currency = (int) $this->context->cookie->id_currency;
         $cart->id_guest = (int) $this->context->cookie->id_guest;
         $cart->id_shop_group = (int) $this->context->shop->id_shop_group;
         $cart->id_shop = $this->context->shop->id;
         if ($this->context->cookie->id_customer) {
             $cart->id_customer = (int) $this->context->cookie->id_customer;
             $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             $cart->id_address_invoice = $cart->id_address_delivery;
         } else {
             $cart->id_address_delivery = 0;
             $cart->id_address_invoice = 0;
         }
         // Needed if the merchant want to give a free product to every visitors
         $this->context->cart = $cart;
         CartRule::autoAddToCart($this->context);
     } else {
         $this->context->cart = $cart;
     }
     /* get page name to display it in body id */
     // Are we in a payment module
     $module_name = '';
     if (Validate::isModuleName(Tools::getValue('module'))) {
         $module_name = Tools::getValue('module');
     }
     if (!empty($this->page_name)) {
         $page_name = $this->page_name;
     } elseif (!empty($this->php_self)) {
         $page_name = $this->php_self;
     } elseif (Tools::getValue('fc') == 'module' && $module_name != '' && Module::getInstanceByName($module_name) instanceof PaymentModule) {
         $page_name = 'module-payment-submit';
     } elseif (preg_match('#^' . preg_quote($this->context->shop->physical_uri, '#') . 'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
         $page_name = 'module-' . $m[1] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[2]);
     } else {
         $page_name = Dispatcher::getInstance()->getController();
         $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
     }
     $this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
     $this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
     /* Breadcrumb */
     $navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
     $this->context->smarty->assign('navigationPipe', $navigationPipe);
     // Automatically redirect to the canonical URL if needed
     if (!empty($this->php_self) && !Tools::getValue('ajax')) {
         $this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
     }
     Product::initPricesComputation();
     $display_tax_label = $this->context->country->display_tax_label;
     if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
         $infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
         $country = new Country((int) $infos['id_country']);
         $this->context->country = $country;
         if (Validate::isLoadedObject($country)) {
             $display_tax_label = $country->display_tax_label;
         }
     }
     $languages = Language::getLanguages(true, $this->context->shop->id);
     $meta_language = array();
     foreach ($languages as $lang) {
         $meta_language[] = $lang['iso_code'];
     }
     $compared_products = array();
     if (Configuration::get('PS_COMPARATOR_MAX_ITEM') && isset($this->context->cookie->id_compare)) {
         $compared_products = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
     }
     $this->context->smarty->assign(array('mobile_device' => $this->context->getMobileDevice(), 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $this->context->cookie, 'page_name' => $page_name, 'hide_left_column' => !$this->display_column_left, 'hide_right_column' => !$this->display_column_right, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'base_uri' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__ . (!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''), 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $this->context->language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => $languages, 'meta_language' => implode(',', $meta_language), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'is_logged' => (bool) $this->context->customer->isLogged(), 'is_guest' => (bool) $this->context->customer->isGuest(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'show_taxes' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE') || !(bool) Group::getCurrent()->show_prices, 'b2b_enable' => (bool) Configuration::get('PS_B2B_ENABLE'), 'request' => $link->getPaginationLink(false, false, false, true), 'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT'), 'quick_view' => (bool) Configuration::get('PS_QUICK_VIEW'), 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 'compared_products' => is_array($compared_products) ? $compared_products : array(), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     // Add the tpl files directory for mobile
     if ($this->useMobileTheme()) {
         $this->context->smarty->assign(array('tpl_mobile_uri' => _PS_THEME_MOBILE_DIR_));
     }
     // Deprecated
     $this->context->smarty->assign(array('id_currency_cookie' => (int) $currency->id, 'logged' => $this->context->customer->isLogged(), 'customerName' => $this->context->customer->logged ? $this->context->cookie->customer_firstname . ' ' . $this->context->cookie->customer_lastname : false));
     $assign_array = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_);
     // Add the images directory for mobile
     if ($this->useMobileTheme()) {
         $assign_array['img_mobile_dir'] = _THEME_MOBILE_IMG_DIR_;
     }
     // Add the CSS directory for mobile
     if ($this->useMobileTheme()) {
         $assign_array['css_mobile_dir'] = _THEME_MOBILE_CSS_DIR_;
     }
     foreach ($assign_array as $assign_key => $assign_value) {
         if (substr($assign_value, 0, 1) == '/' || $protocol_content == 'https://') {
             $this->context->smarty->assign($assign_key, $protocol_content . Tools::getMediaServer($assign_value) . $assign_value);
         } else {
             $this->context->smarty->assign($assign_key, $assign_value);
         }
     }
     /*
      * These shortcuts are DEPRECATED as of version 1.5.
      * Use the Context to access objects instead.
      * Example: $this->context->cart
      */
     self::$cookie = $this->context->cookie;
     self::$cart = $cart;
     self::$smarty = $this->context->smarty;
     self::$link = $link;
     $defaultCountry = $this->context->country;
     $this->displayMaintenancePage();
     if ($this->restrictedCountry) {
         $this->displayRestrictedCountryPage();
     }
     if (Tools::isSubmit('live_edit') && !$this->checkLiveEditAccess()) {
         Tools::redirect('index.php?controller=404');
     }
     $this->iso = $iso;
     $this->context->cart = $cart;
     $this->context->currency = $currency;
 }
Example #30
0
 /**
  * @return bool
  */
 public static function showPrices()
 {
     return Group::isFeatureActive() ? (bool) Group::getCurrent()->show_prices : true;
 }