Divide By Zero Error – Site Crash when Accessing/Removing Cart Items
-
Seems that latest changes are now causing a DivByZero Error, and thus disrupting checkout.
Fatal Error: Uncaught DivisionByZeroError: Division by zero in /home/site/public_html/wp-content/plugins/wholesalex/includes/menu/class-wholesalex-dynamic-rules.php:6658
This:
$get_discount = abs($sale_price - $regular_price) / $regular_price;
$regular_price
returns 0 on “free” custom products, so Does div by zero error happens. Code should check if$regular_price
is 0 and use the value 1. This is a critical error on our site because we have custom products at 0 regular price. For now, because it disrupts our checkout, I have corrected this to:$get_discount = $regular_price == 0 ? 1 : abs($sale_price - $regular_price) / $regular_price;
Thanks!
- You must be logged in to reply to this topic.