Skip to content

Commit

Permalink
Merge pull request #107 from tatiana-scandi/bugfix/fix-pct-option-mul…
Browse files Browse the repository at this point in the history
…ticurrency

Fix calculation of PERCENT option value for discounted product
  • Loading branch information
carinadues authored Jul 1, 2021
2 parents acfe50e + a376223 commit b63448d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Model/Resolver/Product/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ public function resolve(
$options[$key]['value'][$valueKey]['price_type']
= $optionValue->getPriceType() !== null ? strtoupper($optionValue->getPriceType()) : 'DYNAMIC';

$selectionPrice = $this->priceCurrency->convert($options[$key]['value'][$valueKey]['price']);
$selectionPrice = $options[$key]['value'][$valueKey]['price'];
$options[$key]['value'][$valueKey]['price'] = $selectionPrice;
$options[$key]['value'][$valueKey]['currency'] = $currentCurrency;

// Calculate price including tax for option value
$taxablePrice = strtoupper($optionValue->getPriceType()) == 'PERCENT'
? $product->getPrice() * $selectionPrice / 100
? $product->getFinalPrice() * $selectionPrice / 100
: $selectionPrice;
$taxablePrice = $this->priceCurrency->convert($taxablePrice);

$options[$key]['value'][$valueKey]['priceInclTax'] = $this->catalogData->getTaxPrice(
$product, $taxablePrice, true, null, null, null, null, null, null
);
Expand All @@ -116,14 +118,16 @@ public function resolve(
$options[$key]['value']['price_type']
= $option->getPriceType() !== null ? strtoupper($option->getPriceType()) : 'DYNAMIC';

$selectionPrice = $this->priceCurrency->convert($options[$key]['value']['price']);
$selectionPrice = $options[$key]['value']['price'];
$options[$key]['value']['price'] = $selectionPrice;
$options[$key]['value']['currency'] = $currentCurrency;

// Calculate price including tax for option value
$taxablePrice = strtoupper($option->getPriceType()) == 'PERCENT'
? $product->getPrice() * $selectionPrice / 100
? $product->getFinalPrice() * $selectionPrice / 100
: $selectionPrice;
$taxablePrice = $this->priceCurrency->convert($taxablePrice);

$options[$key]['value']['priceInclTax'] = $this->catalogData->getTaxPrice(
$product, $taxablePrice, true, null, null, null, null, null, null
);
Expand Down

0 comments on commit b63448d

Please sign in to comment.