[-] Core: Fix PSCFV-3161 stockage of reduction was bad in database
This commit is contained in:
@@ -109,7 +109,7 @@ function check_all_shop() {
|
|||||||
{assign var=checked value=false}
|
{assign var=checked value=false}
|
||||||
{/if}
|
{/if}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td {if $groupData['disable_shops']}style="font-style:italic;background-color:#CFC4FF"{/if}>
|
||||||
<img style="vertical-align:middle;" alt="" src="../img/admin/lv3_{if $j < count($groupData['shops']) - 1}b{else}f{/if}.png" />
|
<img style="vertical-align:middle;" alt="" src="../img/admin/lv3_{if $j < count($groupData['shops']) - 1}b{else}f{/if}.png" />
|
||||||
<label class="child">
|
<label class="child">
|
||||||
<input class="input_shop"
|
<input class="input_shop"
|
||||||
@@ -118,7 +118,9 @@ function check_all_shop() {
|
|||||||
shop_id="{$shopID}"
|
shop_id="{$shopID}"
|
||||||
name="checkBoxShopAsso_{$table}[{$shopID}]"
|
name="checkBoxShopAsso_{$table}[{$shopID}]"
|
||||||
id="checkedBox_{$shopID}"
|
id="checkedBox_{$shopID}"
|
||||||
{if $checked} checked="checked"{/if} />
|
{if $checked} checked="checked"{/if}
|
||||||
|
{if $groupData['disable_shops']} readonly="readonly"{/if}
|
||||||
|
/>
|
||||||
{$shopData['name']}
|
{$shopData['name']}
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
+9
-18
@@ -2291,26 +2291,15 @@ class ProductCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$condition = '';
|
$condition = '';
|
||||||
$cache_name = (int)$id_cart.'_'.(int)$id_product;
|
$cache_name = (int)$id_cart.'_'.(int)$id_product;
|
||||||
|
|
||||||
if (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION'))
|
|
||||||
{
|
|
||||||
$cache_name = (int)$id_cart.'_'.(int)$id_product.'_'.(int)$id_product_attribute;
|
|
||||||
$condition = ' AND `id_product_attribute` = '.(int)$id_product_attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset(self::$_cart_quantity[$cache_name]) || self::$_cart_quantity[$cache_name] != (int)$quantity)
|
if (!isset(self::$_cart_quantity[$cache_name]) || self::$_cart_quantity[$cache_name] != (int)$quantity)
|
||||||
{
|
|
||||||
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT SUM(`quantity`)
|
SELECT SUM(`quantity`)
|
||||||
FROM `'._DB_PREFIX_.'cart_product`
|
FROM `'._DB_PREFIX_.'cart_product`
|
||||||
WHERE `id_product` = '.(int)$id_product.'
|
WHERE `id_product` = '.(int)$id_product.'
|
||||||
AND `id_cart` = '.(int)$id_cart.' '.$condition
|
AND `id_cart` = '.(int)$id_cart);
|
||||||
);
|
$cart_quantity = self::$_cart_quantity[$cache_name];
|
||||||
|
|
||||||
$cart_quantity = self::$_cart_quantity[$cache_name];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$quantity = ($id_cart && $cart_quantity) ? $cart_quantity : $quantity;
|
|
||||||
$id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
|
$id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
|
||||||
|
|
||||||
// retrieve address informations
|
// retrieve address informations
|
||||||
@@ -2360,7 +2349,7 @@ class ProductCore extends ObjectModel
|
|||||||
$zipcode,
|
$zipcode,
|
||||||
$id_currency,
|
$id_currency,
|
||||||
$id_group,
|
$id_group,
|
||||||
$quantity,
|
$cart_quantity,
|
||||||
$usetax,
|
$usetax,
|
||||||
$decimals,
|
$decimals,
|
||||||
$only_reduc,
|
$only_reduc,
|
||||||
@@ -2370,7 +2359,8 @@ class ProductCore extends ObjectModel
|
|||||||
$use_group_reduction,
|
$use_group_reduction,
|
||||||
$id_customer,
|
$id_customer,
|
||||||
$use_customer_price,
|
$use_customer_price,
|
||||||
$id_cart
|
$id_cart,
|
||||||
|
$quantity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2396,7 +2386,7 @@ class ProductCore extends ObjectModel
|
|||||||
**/
|
**/
|
||||||
public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency,
|
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_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction,
|
||||||
$id_customer = 0, $use_customer_price = true, $id_cart = 0)
|
$id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity)
|
||||||
{
|
{
|
||||||
static $address = null;
|
static $address = null;
|
||||||
|
|
||||||
@@ -2420,7 +2410,8 @@ class ProductCore extends ObjectModel
|
|||||||
$quantity,
|
$quantity,
|
||||||
$id_product_attribute,
|
$id_product_attribute,
|
||||||
$id_customer,
|
$id_customer,
|
||||||
$id_cart
|
$id_cart,
|
||||||
|
$real_quantity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset(self::$_prices[$cache_id]))
|
if (isset(self::$_prices[$cache_id]))
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
return preg_split('/;/', $priority);
|
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, $id_cart = 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, $real_quantity = 0)
|
||||||
{
|
{
|
||||||
if (!SpecificPrice::isFeatureActive())
|
if (!SpecificPrice::isFeatureActive())
|
||||||
return array();
|
return array();
|
||||||
@@ -208,7 +208,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
** The price must not change between the top and the bottom of the page
|
** 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.'-'.(int)$id_cart);
|
$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.'-'.(int)$real_quantity);
|
||||||
if (!array_key_exists($key, self::$_specificPriceCache))
|
if (!array_key_exists($key, self::$_specificPriceCache))
|
||||||
{
|
{
|
||||||
$now = date('Y-m-d H:i:s');
|
$now = date('Y-m-d H:i:s');
|
||||||
@@ -222,14 +222,14 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
AND `id_country` IN (0, '.(int)$id_country.')
|
AND `id_country` IN (0, '.(int)$id_country.')
|
||||||
AND `id_group` IN (0, '.(int)$id_group.')
|
AND `id_group` IN (0, '.(int)$id_group.')
|
||||||
AND `id_customer` IN (0, '.(int)$id_customer.')
|
AND `id_customer` IN (0, '.(int)$id_customer.')
|
||||||
AND `from_quantity` <= '.(int)$quantity.'
|
|
||||||
AND
|
AND
|
||||||
(
|
(
|
||||||
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
|
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
|
||||||
AND
|
AND
|
||||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||||
)
|
)
|
||||||
AND id_cart IN (0, '.(int)$id_cart.')
|
AND id_cart IN (0, '.(int)$id_cart.')'.
|
||||||
|
(($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION')) ? ' AND `from_quantity` <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')' : 'AND `from_quantity` <= '.(int)$real_quantity).'
|
||||||
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
||||||
}
|
}
|
||||||
return self::$_specificPriceCache[$key];
|
return self::$_specificPriceCache[$key];
|
||||||
|
|||||||
@@ -452,14 +452,16 @@ class OrderDetailCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$customer = new Customer((int)$order->id_customer);
|
$customer = new Customer((int)$order->id_customer);
|
||||||
$customer_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
$customer_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||||
|
|
||||||
$this->specificPrice = SpecificPrice::getSpecificPrice(
|
$this->specificPrice = SpecificPrice::getSpecificPrice(
|
||||||
(int)$product['id_product'],
|
(int)$product['id_product'],
|
||||||
(int)$order->id_shop,
|
(int)$order->id_shop,
|
||||||
(int)$order->id_currency,
|
(int)$order->id_currency,
|
||||||
(int)$customer_address->id_country,
|
(int)$customer_address->id_country,
|
||||||
(int)$customer->id_default_group,
|
(int)$customer->id_default_group,
|
||||||
(int)$product['cart_quantity']
|
(int)$product['cart_quantity'],
|
||||||
|
(int)$product['id_product_attribute'],
|
||||||
|
(int)$customer->id,
|
||||||
|
(int)$order->id_cart
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->original_product_price = Product::getPriceStatic($product['id_product'], false, (int)$product['id_product_attribute'], null, null, false, false, 1, false);
|
$this->original_product_price = Product::getPriceStatic($product['id_product'], false, (int)$product['id_product_attribute'], null, null, false, false, 1, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user