[-] Core: Fix PSCFV-3161 stockage of reduction was bad in database

This commit is contained in:
rGaillard
2012-07-13 15:20:53 +00:00
parent fee91d991a
commit 912f1b234d
4 changed files with 21 additions and 26 deletions
@@ -109,7 +109,7 @@ function check_all_shop() {
{assign var=checked value=false}
{/if}
<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" />
<label class="child">
<input class="input_shop"
@@ -118,7 +118,9 @@ function check_all_shop() {
shop_id="{$shopID}"
name="checkBoxShopAsso_{$table}[{$shopID}]"
id="checkedBox_{$shopID}"
{if $checked} checked="checked"{/if} />
{if $checked} checked="checked"{/if}
{if $groupData['disable_shops']} readonly="readonly"{/if}
/>
{$shopData['name']}
</label>
</td>
+9 -18
View File
@@ -2291,26 +2291,15 @@ class ProductCore extends ObjectModel
{
$condition = '';
$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)
{
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_product` = '.(int)$id_product.'
AND `id_cart` = '.(int)$id_cart.' '.$condition
);
$cart_quantity = self::$_cart_quantity[$cache_name];
}
AND `id_cart` = '.(int)$id_cart);
$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');
// retrieve address informations
@@ -2360,7 +2349,7 @@ class ProductCore extends ObjectModel
$zipcode,
$id_currency,
$id_group,
$quantity,
$cart_quantity,
$usetax,
$decimals,
$only_reduc,
@@ -2370,7 +2359,8 @@ class ProductCore extends ObjectModel
$use_group_reduction,
$id_customer,
$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,
$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;
@@ -2420,7 +2410,8 @@ class ProductCore extends ObjectModel
$quantity,
$id_product_attribute,
$id_customer,
$id_cart
$id_cart,
$real_quantity
);
if (isset(self::$_prices[$cache_id]))
+4 -4
View File
@@ -199,7 +199,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, $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())
return array();
@@ -208,7 +208,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.'-'.(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))
{
$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_group` IN (0, '.(int)$id_group.')
AND `id_customer` IN (0, '.(int)$id_customer.')
AND `from_quantity` <= '.(int)$quantity.'
AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
AND
(`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');
}
return self::$_specificPriceCache[$key];
+4 -2
View File
@@ -452,14 +452,16 @@ class OrderDetailCore extends ObjectModel
{
$customer = new Customer((int)$order->id_customer);
$customer_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->specificPrice = SpecificPrice::getSpecificPrice(
(int)$product['id_product'],
(int)$order->id_shop,
(int)$order->id_currency,
(int)$customer_address->id_country,
(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);