Permalink
Browse files

[-] FO : Fix #PSCSX-1165, display correct Group reduction price

  • Loading branch information...
julienbourdeau committed Mar 19, 2014
1 parent 64da015 commit 75692e60d3ed91f7fa9fffaa89c668de5f81db81
@@ -688,7 +688,7 @@ public static function getDefaultAttribute($id_product, $minimum_quantity = 0)
WHERE pa.id_product = '.(int)$id_product;
$result = Db::getInstance()->getValue($sql);
}
$combinations[$id_product][$minimum_quantity] = $result;
return $result;
}
@@ -2120,7 +2120,6 @@ public static function getNewProducts($id_lang, $page_number = 0, $nb_products =
$products_ids[] = $row['id_product'];
// Thus you can avoid one query per product, because there will be only one query for all the products of the cart
Product::cacheFrontFeatures($products_ids, $id_lang);
return Product::getProductsProperties((int)$id_lang, $result);
}
@@ -2678,7 +2677,6 @@ public static function priceCalculation($id_shop, $id_product, $id_product_attri
$id_cart,
$real_quantity
);
if (isset(self::$_prices[$cache_id]))
return self::$_prices[$cache_id];
@@ -2701,7 +2699,7 @@ public static function priceCalculation($id_shop, $id_product, $id_product_attri
$sql->select('0 as id_product_attribute');
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($res as $row)
{
$array_tmp = array(
@@ -2775,7 +2773,7 @@ public static function priceCalculation($id_shop, $id_product, $id_product_attri
if ($reduction_from_category !== false)
$group_reduction = $price * (float)$reduction_from_category;
else // apply group reduction if there is no group reduction for this category
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * (100 - $reduc) / 100) : 0;
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
}
if ($only_reduc)
@@ -3971,7 +3969,6 @@ public static function getProductProperties($id_lang, $row, Context $context = n
$row['quantity'] = 0;
$row = Product::getTaxesInformations($row, $context);
self::$producPropertiesCache[$cache_key] = $row;
return self::$producPropertiesCache[$cache_key];
}
@@ -340,7 +340,7 @@ protected function assignPriceAndTax()
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
'ecotaxTax_rate' => $ecotax_rate,
'productPriceWithoutEcoTax' => (float)$product_price_without_eco_tax,
'group_reduction' => (1 - $group_reduction),
'group_reduction' => $group_reduction,
'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address),
'ecotax' => (!count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((float)$this->product->ecotax) : 0),
'tax_enabled' => Configuration::get('PS_TAX')
@@ -562,31 +562,27 @@ function updateDisplay()
//update display of the the prices in relation to tax, discount, ecotax, and currency criteria
if (!selectedCombination['unavailable'] && productShowPrice == 1)
{
var priceTaxExclWithoutGroupReduction = '';
// retrieve price without group_reduction in order to compute the group reduction after
// the specific price discount (done in the JS in order to keep backward compatibility)
priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);
var tax = (taxRate / 100) + 1;
var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);
if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute'])
combID = $('#idCombination').val();
comb2 = combinationsFromController[combID];
if (comb2.price != 0)
{
if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0)
var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate);
else
var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate);
var taxExclPrice = productPriceTaxExcluded + comb2.price;
productPriceWithoutReductionDisplay = productPriceWithoutReductionDisplay + (comb2.price * tax);
}
else if (product_specific_price.price && product_specific_price.price >= 0)
var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate);
else
var taxExclPrice = productPriceTaxExcluded;
if (!displayPrice && !noTaxForThisProduct)
productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var
else
productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var
productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction;
var reduction = 0;
if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
{
@@ -640,8 +636,9 @@ function updateDisplay()
else
$('#not_impacted_by_discount').hide();
productPriceDisplay -= reduction;
productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);
productPriceDisplay = ps_round(productPriceDisplay * (1 - group_reduction), 2);
var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
@@ -267,7 +267,7 @@
{if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
</span>
</p>
<p id="old_price"{if (!$product->specificPrice || !$product->specificPrice.reduction) && $group_reduction == 1} class="hidden"{/if}>
<p id="old_price"{if (!$product->specificPrice || !$product->specificPrice.reduction) && $group_reduction == 0} class="hidden"{/if}>
{if $priceDisplay >= 0 && $priceDisplay <= 2}
<span id="old_price_display">{if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction}{/if}</span>
<!-- {if $tax_enabled && $display_tax_label == 1}{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}{/if} -->
@@ -665,6 +665,7 @@
{addJsDef currentDate=$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}
{if isset($combinations) && $combinations}
{addJsDef combinations=$combinations}
{addJsDef combinationsFromController=$combinations}
{/if}
{if isset($combinationImages) && $combinationImages}
{addJsDef combinationImages=$combinationImages}
@@ -723,7 +724,7 @@
{else}
{addJsDef specific_price=0}
{/if}
{addJsDef specific_currency=($product->specificPrice && $product->specificPrice.id_currency)|boolval}
{addJsDef specific_currency=($product->specificPrice && $product->specificPrice.id_currency)|boolval} {* TODO: remove if always false *}
{addJsDef stock_management=$stock_management|intval}
{addJsDef taxRate=$tax_rate|floatval}
{addJsDefL name=doesntExist}{l s='This combination does not exist for this product. Please select another combination.' js=1}{/addJsDefL}

0 comments on commit 75692e6

Please sign in to comment.