Skip to content

Commit

Permalink
Rounding audit Product::getPriceStatic().
Browse files Browse the repository at this point in the history
Audit is to find hardcoded rounding constants and to replace them
with _TB_PRICE_DATABASE_PRECISION_, or to remove them in case
parameters match the method's defaults.
  • Loading branch information
Traumflug committed Mar 2, 2019
1 parent a23cdf8 commit 86cba07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Adapter/Adapter_ProductPriceCalculator.php
Expand Up @@ -64,7 +64,7 @@ public function getProductPrice(
$idProduct, $idProduct,
$usetax = true, $usetax = true,
$idProductAttribute = null, $idProductAttribute = null,
$decimals = 6, $decimals = _TB_PRICE_DATABASE_PRECISION_,
$divisor = null, $divisor = null,
$onlyReduc = false, $onlyReduc = false,
$usereduc = true, $usereduc = true,
Expand Down
8 changes: 7 additions & 1 deletion classes/Tools.php
Expand Up @@ -2600,7 +2600,13 @@ public static function ucwords($str)
public static function orderbyPrice(&$array, $order_way) public static function orderbyPrice(&$array, $order_way)
{ {
foreach ($array as &$row) { foreach ($array as &$row) {
$row['price_tmp'] = Product::getPriceStatic($row['id_product'], true, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : null), 2); $row['price_tmp'] = Product::getPriceStatic(
$row['id_product'],
true,
(isset($row['id_product_attribute'])
&& ! empty($row['id_product_attribute'])) ?
(int) $row['id_product_attribute'] : null
);
} }


unset($row); unset($row);
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminOrdersController.php
Expand Up @@ -2709,7 +2709,7 @@ public function ajaxProcessLoadProductInformation()


$decimals = 0; $decimals = 0;
if ($currency->decimals) { if ($currency->decimals) {
$ecimals = Configuration::get('PS_PRICE_DISPLAY_PRECISION'); $decimals = Configuration::get('PS_PRICE_DISPLAY_PRECISION');
} }
$this->ajaxDie(json_encode([ $this->ajaxDie(json_encode([
'result' => true, 'result' => true,
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/ParentOrderController.php
Expand Up @@ -364,7 +364,7 @@ protected function _assignSummaryInformations()
$product['id_product'], $product['id_product'],
!Product::getTaxCalculationMethod(), !Product::getTaxCalculationMethod(),
$product['id_product_attribute'], $product['id_product_attribute'],
6, _TB_PRICE_DATABASE_PRECISION_,
null, null,
false, false,
false, false,
Expand Down

0 comments on commit 86cba07

Please sign in to comment.