Skip to content

Commit

Permalink
Merge pull request #26824 from mpaolino/fix_26553
Browse files Browse the repository at this point in the history
Avoid using _PS_PRICE_COMPUTE_PRECISION_
  • Loading branch information
Progi1984 committed Mar 21, 2022
2 parents ac763ef + ad342cd commit a6e1caa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ public function validateOrder(
// Amount paid by customer is not the right one -> Status = payment error
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
// if ($order->total_paid != $order->total_paid_real)
// We use number_format in order to compare two string
if ($order_status->logable && number_format($cart_total_paid, Context::getContext()->getComputingPrecision()) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
// We use number_format to convert the numbers to strings and strict inequality to compare them to avoid auto reconversions to numbers in PHP < 8.0
$comp_precision = Context::getContext()->getComputingPrecision();
if ($order_status->logable && (number_format($cart_total_paid, $comp_precision) !== number_format($amount_paid, $comp_precision))) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Total paid amount does not match cart total', 3, null, 'Cart', (int) $id_cart, true);
$id_order_state = Configuration::get('PS_OS_ERROR');
}

Expand Down

0 comments on commit a6e1caa

Please sign in to comment.