Plugin: BuyCourses: Fix issue over-formatting values greater than 1000

Author: @juancpbinario
pull/4737/head
juancpbinario 2 years ago committed by GitHub
parent 39219c5fa3
commit efb9fbff8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      plugin/buycourses/src/buy_course_plugin.class.php

@ -3107,7 +3107,7 @@ class BuyCoursesPlugin extends Plugin
$priceWithoutTax = $product['price']; $priceWithoutTax = $product['price'];
$product['total_price'] = $product['price']; $product['total_price'] = $product['price'];
$product['tax_amount'] = 0; $product['tax_amount'] = 0;
$precision = 2;
if ($this->checkTaxEnabledInProduct($productType)) { if ($this->checkTaxEnabledInProduct($productType)) {
if (is_null($product['tax_perc'])) { if (is_null($product['tax_perc'])) {
$globalParameters = $this->getGlobalParameters(); $globalParameters = $this->getGlobalParameters();
@ -3118,7 +3118,7 @@ class BuyCoursesPlugin extends Plugin
} }
//$taxPerc = is_null($product['tax_perc']) ? $globalTaxPerc : $product['tax_perc']; //$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; $product['tax_amount'] = $taxAmount;
$priceWithTax = $priceWithoutTax + $taxAmount; $priceWithTax = $priceWithoutTax + $taxAmount;
$product['total_price'] = $priceWithTax; $product['total_price'] = $priceWithTax;
@ -3126,25 +3126,25 @@ class BuyCoursesPlugin extends Plugin
$product['tax_perc_show'] = $taxPerc; $product['tax_perc_show'] = $taxPerc;
$product['price_formatted'] = $this->getPriceWithCurrencyFromIsoCode( $product['price_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['price'], $precision), $product['price'],
$product['iso_code'] $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( $product['total_price_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['total_price'], $precision), $product['total_price'],
$product['iso_code'] $product['iso_code']
); );
if ($coupon != null) { if ($coupon != null) {
$product['discount_amount_formatted'] = $this->getPriceWithCurrencyFromIsoCode( $product['discount_amount_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['discount_amount'], $precision), $product['discount_amount'],
$product['iso_code'] $product['iso_code']
); );
$product['price_without_discount_formatted'] = $this->getPriceWithCurrencyFromIsoCode( $product['price_without_discount_formatted'] = $this->getPriceWithCurrencyFromIsoCode(
number_format($product['price_without_discount'], $precision), $product['price_without_discount'],
$product['iso_code'] $product['iso_code']
); );
} }

Loading…
Cancel
Save