// Add specific_price management for backoffice order && fix installer
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11520 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+5
-3
@@ -2308,7 +2308,8 @@ class ProductCore extends ObjectModel
|
||||
$specific_price_output,
|
||||
$use_group_reduction,
|
||||
$id_customer,
|
||||
$use_customer_price
|
||||
$use_customer_price,
|
||||
$id_cart
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2334,7 +2335,7 @@ class ProductCore extends ObjectModel
|
||||
**/
|
||||
public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency,
|
||||
$id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction,
|
||||
$id_customer = 0, $use_customer_price = true)
|
||||
$id_customer = 0, $use_customer_price = true, $id_cart = 0)
|
||||
{
|
||||
if (!$use_customer_price)
|
||||
$id_customer = 0;
|
||||
@@ -2357,7 +2358,8 @@ class ProductCore extends ObjectModel
|
||||
$id_group,
|
||||
$quantity,
|
||||
$id_product_attribute,
|
||||
$id_customer
|
||||
$id_customer,
|
||||
$id_cart
|
||||
);
|
||||
|
||||
if (isset(self::$_prices[$cache_id]))
|
||||
|
||||
@@ -29,6 +29,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
{
|
||||
public $id_product;
|
||||
public $id_specific_price_rule = 0;
|
||||
public $id_cart = 0;
|
||||
public $id_product_attribute;
|
||||
public $id_shop;
|
||||
public $id_group_shop;
|
||||
@@ -52,6 +53,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_currency' => array('type' => self::TYPE_INT, 'required' => true),
|
||||
@@ -109,20 +111,31 @@ class SpecificPriceCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getByProductId($id_product)
|
||||
public static function getByProductId($id_product, $id_product_attribute = false, $id_cart = 0)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'specific_price`
|
||||
WHERE `id_product` = '.(int)$id_product);
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND id_product_attribute='.(int)$id_product_attribute.'
|
||||
AND id_cart='.(int)$id_cart);
|
||||
}
|
||||
|
||||
public static function deleteByIdCart($id_cart, $id_product = false, $id_product_attribute = false)
|
||||
{
|
||||
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'specific_price`
|
||||
WHERE id_cart='.(int)$id_cart.
|
||||
($id_product ? ' AND id_product='.(int)$id_product.' AND id_product_attribute='.(int)$id_product_attribute : ''));
|
||||
}
|
||||
|
||||
public static function getIdsByProductId($id_product)
|
||||
public static function getIdsByProductId($id_product, $id_product_attribute = false, $id_cart = 0)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT `id_specific_price`
|
||||
FROM `'._DB_PREFIX_.'specific_price`
|
||||
WHERE `id_product` = '.(int)$id_product);
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND id_product_attribute='.(int)$id_product_attribute.'
|
||||
AND id_cart='.(int)$id_cart);
|
||||
}
|
||||
|
||||
// score generation for quantity discount
|
||||
@@ -163,7 +176,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
return preg_split('/;/', $priority);
|
||||
}
|
||||
|
||||
public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute = null, $id_customer = 0)
|
||||
public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute = null, $id_customer = 0, $id_cart = 0)
|
||||
{
|
||||
if (!self::isFeatureActive())
|
||||
return array();
|
||||
@@ -172,7 +185,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
** The price must not change between the top and the bottom of the page
|
||||
*/
|
||||
|
||||
$key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute);
|
||||
$key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart);
|
||||
if (!array_key_exists($key, self::$_specificPriceCache))
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
@@ -193,6 +206,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
AND
|
||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||
)
|
||||
AND id_cart='.(int)$id_cart.'
|
||||
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC');
|
||||
}
|
||||
return self::$_specificPriceCache[$key];
|
||||
|
||||
@@ -262,6 +262,13 @@ class OrderCore extends ObjectModel
|
||||
return parent::getFields();
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = true)
|
||||
{
|
||||
if (parent::add($autodate, $null_values))
|
||||
return SpecificPrice::deleteByIdCart($this->id_cart);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTaxCalculationMethod()
|
||||
{
|
||||
return (int)($this->_taxCalculationMethod);
|
||||
|
||||
Reference in New Issue
Block a user