From 56819e35738eb2d8544baed4bdde555b4a04dd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Thu, 6 Dec 2012 16:38:31 +0100 Subject: [PATCH] [-] FO: Fix some tax_display_method value for not default customer group --- classes/Cart.php | 4 +--- classes/Product.php | 7 ++++--- modules/blockcart/blockcart.php | 8 +------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index c821ffe58..dc72c75d2 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -154,7 +154,6 @@ class CartCore extends ObjectModel $customer = Context::getContext()->customer; else $customer = new Customer((int)$this->id_customer); - $this->_taxCalculationMethod = Group::getPriceDisplayMethod((int)$customer->id_default_group); if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) { @@ -162,8 +161,7 @@ class CartCore extends ObjectModel $this->save(); } } - else - $this->_taxCalculationMethod = Group::getDefaultPriceDisplayMethod(); + $this->_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id); } diff --git a/classes/Product.php b/classes/Product.php index 88d789415..f7b1715a1 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -225,7 +225,7 @@ class ProductCore extends ObjectModel */ public $category; - public static $_taxCalculationMethod = PS_TAX_EXC; + public static $_taxCalculationMethod = null; protected static $_prices = array(); protected static $_pricesLevel2 = array(); protected static $_incat = array(); @@ -510,8 +510,9 @@ class ProductCore extends ObjectModel public static function getTaxCalculationMethod($id_customer = null) { - if ($id_customer) - Product::initPricesComputation((int)$id_customer); + if (self::$_taxCalculationMethod === null || $id_customer !== null) + Product::initPricesComputation($id_customer); + return (int)self::$_taxCalculationMethod; } diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 5c1677ea6..0bb0da61d 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -53,13 +53,7 @@ class BlockCart extends Module else $currency = $this->context->currency; - if ($params['cart']->id_customer) - { - $customer = new Customer((int)$params['cart']->id_customer); - $taxCalculationMethod = Group::getPriceDisplayMethod((int)$customer->id_default_group); - } - else - $taxCalculationMethod = Group::getDefaultPriceDisplayMethod(); + $taxCalculationMethod = Group::getPriceDisplayMethod((int)Group::getCurrent()->id); $useTax = !($taxCalculationMethod == PS_TAX_EXC);