Skip to content

Commit

Permalink
Plugin: BuyCourses: Fix issue over-formatting values greater than 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
juancpbinario committed May 31, 2023
1 parent 39219c5 commit efb9fbf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions plugin/buycourses/src/buy_course_plugin.class.php
Expand Up @@ -3107,7 +3107,7 @@ public function setPriceSettings(array &$product, int $productType, array $coupo
$priceWithoutTax = $product['price'];
$product['total_price'] = $product['price'];
$product['tax_amount'] = 0;
$precision = 2;

if ($this->checkTaxEnabledInProduct($productType)) {
if (is_null($product['tax_perc'])) {
$globalParameters = $this->getGlobalParameters();
Expand All @@ -3118,33 +3118,33 @@ public function setPriceSettings(array &$product, int $productType, array $coupo
}
//$taxPerc = is_null($product['tax_perc']) ? $globalTaxPerc : $product['tax_perc'];

$taxAmount = round($priceWithoutTax * $taxPerc / 100, $precision);
$taxAmount = round($priceWithoutTax * $taxPerc / 100, 2);
$product['tax_amount'] = $taxAmount;
$priceWithTax = $priceWithoutTax + $taxAmount;
$product['total_price'] = $priceWithTax;
}

$product['tax_perc_show'] = $taxPerc;
$product['price_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['price'], $precision),
$product['price'],
$product['iso_code']
);

$product['tax_amount_formatted'] = number_format($product['tax_amount'], $precision);
$product['tax_amount_formatted'] = number_format($product['tax_amount'], 2);

$product['total_price_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['total_price'], $precision),
$product['total_price'],
$product['iso_code']
);

if ($coupon != null) {
$product['discount_amount_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['discount_amount'], $precision),
$product['discount_amount'],
$product['iso_code']
);

$product['price_without_discount_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['price_without_discount'], $precision),
$product['price_without_discount'],
$product['iso_code']
);
}
Expand Down

0 comments on commit efb9fbf

Please sign in to comment.