diff --git a/classes/Customer.php b/classes/Customer.php index 55429fcb3..e6bccab43 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -42,7 +42,7 @@ class CustomerCore extends ObjectModel public $id_gender = 0; /** @var integer Default group ID */ - public $id_default_group = _PS_DEFAULT_CUSTOMER_GROUP_; + public $id_default_group; /** @var string Lastname */ public $lastname; @@ -189,7 +189,13 @@ class CustomerCore extends ObjectModel protected static $_defaultGroupId = array(); protected static $_customerHasAddress = array(); protected static $_customer_groups = array(); - + + public function __contruct($id = null) + { + $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); + parent::__construct($id); + } + public function add($autodate = true, $null_values = true) { $this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id; @@ -201,11 +207,11 @@ class CustomerCore extends ObjectModel if ($this->newsletter && !Validate::isDate($this->newsletter_date_add)) $this->newsletter_date_add = date('Y-m-d H:i:s'); - if ($this->id_default_group == _PS_DEFAULT_CUSTOMER_GROUP_) + if ($this->id_default_group == Configuration::get('PS_CUSTOMER_GROUP')) if ($this->is_guest) - $this->id_default_group = Configuration::get('PS_GUEST_GROUP'); + $this->id_default_group = (int)Configuration::get('PS_GUEST_GROUP'); else - $this->id_default_group = Configuration::get('PS_CUSTOMER_GROUP'); + $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); /* Can't create a guest customer, if this feature is disabled */ if ($this->is_guest && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) diff --git a/classes/Group.php b/classes/Group.php index 5ae7322bd..464112be8 100644 --- a/classes/Group.php +++ b/classes/Group.php @@ -157,7 +157,7 @@ class GroupCore extends ObjectModel public function delete() { - if ($this->id == _PS_DEFAULT_CUSTOMER_GROUP_) + if ($this->id == (int)Configuration::get('PS_CUSTOMER_GROUP')) return false; if (parent::delete()) { diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php index 251e2059a..8c0bccfa1 100644 --- a/classes/LocalizationPack.php +++ b/classes/LocalizationPack.php @@ -432,7 +432,7 @@ class LocalizationPackCore $attributes = $xml->group_default->attributes(); if (isset($attributes['price_display_method']) && in_array((int)$attributes['price_display_method'], array(0, 1))) { - $group = new Group((int)_PS_DEFAULT_CUSTOMER_GROUP_); + $group = new Group((int)Configuration::get('PS_CUSTOMER_GROUP')); $group->price_display_method = (int)$attributes['price_display_method']; if (!$group->save()) $this->_errors[] = Tools::displayError('An error occurred during the default group update'); diff --git a/classes/Product.php b/classes/Product.php index e22850083..9a25030fa 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -2399,7 +2399,7 @@ class ProductCore extends ObjectModel if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product)) die(Tools::displayError()); // Initializations - $id_group = (isset($context->customer) ? $context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); + $id_group = (isset($context->customer) ? $context->customer->id_default_group : (int)Configuration::get('PS_CUSTOMER_GROUP')); // If there is cart in context or if the specified id_cart is different from the context cart id if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart)) diff --git a/classes/webservice/WebserviceRequest.php b/classes/webservice/WebserviceRequest.php index 2df91e930..75c94b6be 100644 --- a/classes/webservice/WebserviceRequest.php +++ b/classes/webservice/WebserviceRequest.php @@ -333,7 +333,7 @@ class WebserviceRequestCore $id_country = (int)(isset($value['country']) ? $value['country'] : (Configuration::get('PS_COUNTRY_DEFAULT'))); $id_state = (int)(isset($value['state']) ? $value['state'] : 0); $id_currency = (int)(isset($value['currency']) ? $value['currency'] : Configuration::get('PS_CURRENCY_DEFAULT')); - $id_group = (int)(isset($value['group']) ? $value['group'] : Configuration::get('_PS_DEFAULT_CUSTOMER_GROUP_')); + $id_group = (int)(isset($value['group']) ? $value['group'] : (int)Configuration::get('PS_CUSTOMER_GROUP')); $quantity = (int)(isset($value['quantity']) ? $value['quantity'] : 1); $use_tax = (int)(isset($value['use_tax']) ? $value['use_tax'] : Configuration::get('PS_TAX')); $decimals = (int)(isset($value['decimals']) ? $value['decimals'] : Configuration::get('PS_PRICE_ROUND_MODE')); diff --git a/config/defines.inc.php b/config/defines.inc.php index c4e9e5940..8ce70b580 100755 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -142,7 +142,7 @@ define('_STOCK_MOVEMENT_MISSING_REASON_', 4); /** * @deprecated 1.5.0.1 - * @see const PS_CUSTOMER_GROUP + * @see Configuration::get('PS_CUSTOMER_GROUP') */ define('_PS_DEFAULT_CUSTOMER_GROUP_', 3); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 3c1935468..c57997bbd 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -275,7 +275,7 @@ class ProductControllerCore extends FrontController protected function assignPriceAndTax() { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); - $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); + $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : (int)Configuration::get('PS_CUSTOMER_GROUP')); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);