Skip to content

Commit

Permalink
Fix pricing when using with&without tax with customer groups
Browse files Browse the repository at this point in the history
When using prices with and without taxes, there are
multiple entries in the $fields array. When looping through
the groups $product->getPriceModel()->getFinalPrice() is
called for each group. This sets the data['final_price'] on
the product model each time it is called.

This means that on the second loop of the field array,
when the call to set $special_price uses $product->getFinalPrice()
it is getting value set for the final group in the previous
iteration.

This patch changes the assignment of special_price to recalculate
the final_price everytime, it also moves it out of the currency
loop because the result doesn't depend on the currency.

(cherry picked from commit 77dad50c58c81b6e95772230bad89e05b60c9b2e)
  • Loading branch information
rbrown committed Mar 26, 2019
1 parent 74078a5 commit 6731ddb
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,21 +528,21 @@ protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_produc

foreach ($fields as $field => $with_tax) {
$customData[$field] = array();
$field_price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null);
$field_special_price = (double) $taxHelper->getPrice($product, $product->getPriceModel()->getFinalPrice(1, $product), $with_tax, null, null, null, $product->getStore(), null);

foreach ($currencies as $currency_code) {
$customData[$field][$currency_code] = array();

$price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null);
$price = $directoryHelper->currencyConvert($price, $baseCurrencyCode, $currency_code);
$price = $directoryHelper->currencyConvert($field_price, $baseCurrencyCode, $currency_code);
$price += $weeeTaxAmount;

$special_price = $directoryHelper->currencyConvert($field_special_price, $baseCurrencyCode, $currency_code);
$special_price += $weeeTaxAmount;

$customData[$field][$currency_code]['default'] = $price;
$customData[$field][$currency_code]['default_formated'] = $this->formatPrice($price, false, $currency_code);

$special_price = (double) $taxHelper->getPrice($product, $product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null);
$special_price = $directoryHelper->currencyConvert($special_price, $baseCurrencyCode, $currency_code);
$special_price += $weeeTaxAmount;

if ($customer_groups_enabled) {
// If fetch special price for groups

Expand Down

0 comments on commit 6731ddb

Please sign in to comment.