// improve multishop code, id_shop has an id different than 0 even if share_customer or share_order is true
This commit is contained in:
+42
-28
@@ -84,8 +84,20 @@ class CartCore extends ObjectModel
|
|||||||
protected static $_nbProducts = array();
|
protected static $_nbProducts = array();
|
||||||
protected static $_isVirtualCart = array();
|
protected static $_isVirtualCart = array();
|
||||||
|
|
||||||
|
protected $fieldsRequired = array('id_currency', 'id_lang');
|
||||||
|
protected $fieldsValidate = array(
|
||||||
|
'id_address_delivery' => 'isUnsignedId',
|
||||||
|
'id_carrier' => 'isUnsignedId',
|
||||||
|
'id_address_invoice' => 'isUnsignedId',
|
||||||
|
'id_currency' => 'isUnsignedId',
|
||||||
|
'id_customer' => 'isUnsignedId',
|
||||||
|
'id_guest' => 'isUnsignedId',
|
||||||
|
'id_lang' => 'isUnsignedId',
|
||||||
|
'recyclable' => 'isBool',
|
||||||
|
'gift' => 'isBool',
|
||||||
|
'gift_message' => 'isMessage',
|
||||||
|
'allow_seperated_package' => 'isBool'
|
||||||
|
);
|
||||||
|
|
||||||
protected $_products = null;
|
protected $_products = null;
|
||||||
protected static $_totalWeight = array();
|
protected static $_totalWeight = array();
|
||||||
@@ -94,31 +106,9 @@ class CartCore extends ObjectModel
|
|||||||
protected static $_taxes_rate = null;
|
protected static $_taxes_rate = null;
|
||||||
protected static $_attributesLists = array();
|
protected static $_attributesLists = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ObjectModel::$definition
|
|
||||||
*/
|
|
||||||
public static $definition = array(
|
public static $definition = array(
|
||||||
'table' => 'cart',
|
'table' => 'cart',
|
||||||
'primary' => 'id_cart',
|
'primary' => 'id_cart',
|
||||||
'fields' => array(
|
|
||||||
'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_address_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
|
||||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
|
||||||
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
|
||||||
'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
|
||||||
'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
|
||||||
'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'),
|
|
||||||
'delivery_option' => array('type' => self::TYPE_STRING),
|
|
||||||
'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32),
|
|
||||||
'allow_seperated_package' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
|
||||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
|
||||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
@@ -148,6 +138,32 @@ class CartCore extends ObjectModel
|
|||||||
const ONLY_WRAPPING = 6;
|
const ONLY_WRAPPING = 6;
|
||||||
const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7;
|
const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7;
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
$this->validateFields();
|
||||||
|
|
||||||
|
$fields['id_group_shop'] = (int)$this->id_group_shop;
|
||||||
|
$fields['id_shop'] = (int)$this->id_shop;
|
||||||
|
|
||||||
|
$fields['id_address_delivery'] = (int)$this->id_address_delivery;
|
||||||
|
$fields['id_address_invoice'] = (int)$this->id_address_invoice;
|
||||||
|
$fields['id_currency'] = (int)$this->id_currency;
|
||||||
|
$fields['id_customer'] = (int)$this->id_customer;
|
||||||
|
$fields['id_carrier'] = (int)$this->id_carrier;
|
||||||
|
$fields['id_guest'] = (int)$this->id_guest;
|
||||||
|
$fields['id_lang'] = (int)$this->id_lang;
|
||||||
|
$fields['recyclable'] = (int)$this->recyclable;
|
||||||
|
$fields['gift'] = (int)$this->gift;
|
||||||
|
$fields['secure_key'] = pSQL($this->secure_key);
|
||||||
|
$fields['gift_message'] = pSQL($this->gift_message);
|
||||||
|
$fields['date_add'] = pSQL($this->date_add);
|
||||||
|
$fields['date_upd'] = pSQL($this->date_upd);
|
||||||
|
$fields['allow_seperated_package'] = (int)$this->allow_seperated_package;
|
||||||
|
$fields['delivery_option'] = $this->delivery_option;
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct($id = null, $id_lang = null)
|
public function __construct($id = null, $id_lang = null)
|
||||||
{
|
{
|
||||||
parent::__construct($id, $id_lang);
|
parent::__construct($id, $id_lang);
|
||||||
@@ -171,8 +187,7 @@ class CartCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$this->id_lang)
|
if (!$this->id_lang)
|
||||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||||
if (Context::getContext()->shop->getGroup()->share_order == true)
|
|
||||||
$this->id_shop = null;
|
|
||||||
$return = parent::add($autodate);
|
$return = parent::add($autodate);
|
||||||
Hook::exec('cart');
|
Hook::exec('cart');
|
||||||
|
|
||||||
@@ -186,8 +201,7 @@ class CartCore extends ObjectModel
|
|||||||
|
|
||||||
if (isset(self::$_totalWeight[$this->id]))
|
if (isset(self::$_totalWeight[$this->id]))
|
||||||
unset(self::$_totalWeight[$this->id]);
|
unset(self::$_totalWeight[$this->id]);
|
||||||
if (Context::getContext()->shop->getGroup()->share_order == true)
|
|
||||||
$this->id_shop = null;
|
|
||||||
$this->_products = null;
|
$this->_products = null;
|
||||||
$return = parent::update();
|
$return = parent::update();
|
||||||
Hook::exec('cart');
|
Hook::exec('cart');
|
||||||
|
|||||||
@@ -187,10 +187,7 @@ class CustomerCore extends ObjectModel
|
|||||||
|
|
||||||
public function add($autodate = true, $null_values = true)
|
public function add($autodate = true, $null_values = true)
|
||||||
{
|
{
|
||||||
if (Context::getContext()->shop->getGroup()->share_customer == true)
|
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->getID();
|
||||||
$this->id_shop = null;
|
|
||||||
else
|
|
||||||
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->getID();
|
|
||||||
$this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->getGroupID();
|
$this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->getGroupID();
|
||||||
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
|
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
|
||||||
$this->secure_key = md5(uniqid(rand(), true));
|
$this->secure_key = md5(uniqid(rand(), true));
|
||||||
|
|||||||
@@ -298,21 +298,6 @@ class OrderCore extends ObjectModel
|
|||||||
$this->_taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
|
$this->_taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($autodate = true, $null_values = false)
|
|
||||||
{
|
|
||||||
if (Context::getContext()->shop->getGroup()->share_order == true)
|
|
||||||
$this->id_shop = null;
|
|
||||||
return parent::add($autodate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update($null_values = false)
|
|
||||||
{
|
|
||||||
if (Context::getContext()->shop->getGroup()->share_order == true)
|
|
||||||
$this->id_shop = null;
|
|
||||||
$return = parent::update();
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTaxCalculationMethod()
|
public function getTaxCalculationMethod()
|
||||||
{
|
{
|
||||||
return (int)($this->_taxCalculationMethod);
|
return (int)($this->_taxCalculationMethod);
|
||||||
|
|||||||
@@ -758,13 +758,12 @@ class ShopCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($shop_group_id && ($share == Shop::SHARE_CUSTOMER || $share == Shop::SHARE_ORDER))
|
if ($shop_id || $shop_group_id)
|
||||||
$restriction = ' AND '.$alias.'id_group_shop = '.$shop_group_id.' AND '.$alias.'id_shop = 0';
|
|
||||||
else if ($shop_id || $shop_group_id)
|
|
||||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
|
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
|
||||||
//else if ($share == Shop::SHARE_STOCK)
|
//else if ($share == Shop::SHARE_STOCK)
|
||||||
// $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
|
// $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $restriction;
|
return $restriction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user