Uncaught DivisionByZeroError: Division by zero in /home/site/webapps/site/web/app/themes/bricks/includes/woocommerce.php:756
I believe the problem is that some products have weird prices or discounts. But this isn’t a reason to throw such an error, and it should be handled with some defaults or ignored.
Error Details:
Type:DivisionByZeroError
Message: Division by zero
Location:woocommerce.php in the theme’s WooCommerce integration module
I’m not really sure what my client did there. Maybe they had a product with price 0? Not sure. I didn’t spent the time to look for the specific product with the problem.
I tried to reproduce this again, but it didn’t show up. So maybe they updated the product because I told them that this error was caused by a 0 regular price somewhere. So I’m not sure.
Unfortunately, I can’t reproduce it either with the regular or the sale price. So, I don’t see any need for action at the moment. Please get in touch if you know how to reproduce the problem, and we’ll be happy to take a look at it
Looking at the page structure in inspect I can see that the SALE badge for the previous item showed up, while the next one crashed. The images are both Bundle items, both with a discounted price, and both had stock values and prices correctly set. So it doesn’t have anything to do with the price division by 0 as I previously thought. Or maybe the bundle has a price of 0? let me check…
Also, why do the badges show differently? Some have “SALE” text and some have actual percentage reduction? It seems to crash only for percentage badges because only then it tries to calculate the price.
Hi Cristian,
How did you add the products? Probably imported, right? Normally it doesn’t seem to be possible to specify only a sale price. If I leave out the regular price, the sale price field empties automatically (independent of Bricks).
Have you tried it temporarily with a default theme? You should get the same problem.
Presumably because they are different item types. Simple products show the percentage discount because the price is explicit. SALE is displayed for variable or grouped products.
Also, I confirm I can save the page without a regular price since this is a bundled product. However, I am not the one who adds these products; the owner of the site does. I told them to be careful and add a regular price, but it seems they often miss it.