Wednesday, March 01, 2023

Prestashop 1.7x / 8.x "NAN" cannot be interpreted as a number

No comments:

\src\Core\Cart\CartRuleCalculator.php, function applyCartRule has the same line 2x. This line will generate a NAN if you have a free product via a cart rule in your basket, and another cart rule at the same time.

$discountAmountTaxExcl = $discountAmountTaxIncl / (1 + $taxRate)

The following code will work around the problem.

$discountAmountTaxExcl = ($discountAmountTaxIncl > 0) ? 
$discountAmountTaxIncl / (1 + $taxRate) : 0
;