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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getProductPrice(
$idProduct,
$usetax = true,
$idProductAttribute = null,
$decimals = 6,
$decimals = _TB_PRICE_DATABASE_PRECISION_,
$divisor = null,
$onlyReduc = false,
$usereduc = true,
Expand Down
8 changes: 7 additions & 1 deletion classes/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,13 @@ public static function ucwords($str)
public static function orderbyPrice(&$array, $order_way)
{
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);
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ public function ajaxProcessLoadProductInformation()

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

0 comments on commit 86cba07

Please sign in to comment.