Page 1 of 1

Division by zero?

Posted: Sat Aug 11, 2012 4:41 am
by Jopke
I'm not sure if this is a bug but I suspect it might me. I'm using 1.5.3.1 and I have only UPS set up for shipping. When I get to step 4 of the checkout process I get this message:

Warning: Division by zero in /home/casino/public_html/system/library/weight.php on line 38

And then the shipping method choice has no radio button which means I can't choose a shipping method.

not sure what to do...

Re: Division by zero?

Posted: Sat Aug 11, 2012 6:46 am
by MrTech
I've had this problem in the past and the fix has always been an empty something or other.

I had a mod that when there were no products in a category - division by zero

Based on your error, my best guess is to look for the weight of a product which is empty and should not be.

Re: Division by zero?

Posted: Sat Aug 11, 2012 6:53 am
by Jopke
ok thanks man. I will look to see if the products have actual weights and look into clearing caches and all that. thanks.

Re: Division by zero?

Posted: Sat Aug 11, 2012 9:24 am
by MrTech
Don't forget to report your findings here in case it can help other users.

Re: Division by zero?

Posted: Sat Aug 11, 2012 9:55 am
by Johnathan
This can happen if you've set a weight class for a product, and then deleted that weight class. The products then have no weight class applied, so it uses 0 for the weight_class_id.

The fix is to resave your products, or take a look in your database's "product" table and see if any of them have 0 for the weight_class_id.

Re: Division by zero?

Posted: Sat Aug 11, 2012 10:35 am
by Jopke
OK so I was able to fix the first part of the problem with your suggestions. It did indeed have to do with weight class. In my UPS settings I had everything set up to deal with lb but some of my products had either kg or nothing listed. So it looks like if I change everything to pounds to match the UPS settings it works fine.

The 2nd part of my problem is still there though. It lists "United Parcel Service" as the shipping method during checkout but there is no way to choose it. If I just try to move on it says "Warning, Shipping Method Required"...

Re: Division by zero?

Posted: Sat Aug 11, 2012 10:51 am
by allenshea

Re: Division by zero?

Posted: Tue Dec 04, 2012 5:14 pm
by webgeeze
I know this is an older post but I experience the same problem on OC 1.5.4 and I wanted to share my fix

In my case, I have migrated data from storesprite to opencart and when doing so, the weight_class_id was set to 0. In order to fix the issue, I ran a sql command in php my admin as follows. The error dissapeared.

UPDATE `product` SET `weight_class_id` = '1' WHERE `weight_class_id` = '0'

Most will know how to do this simple task. For those who don't, simply log into PHP Myadmin (ask your host) and locate your database. Click on the products table in your database and then click the SQL button. Paste the command above and it will change the weight_class_id from 0 to 1.

*assumes you are not using a prefix on the database name and tables. If you have a prefix, change the text within the ' ' above e.g mysite_product rather than product.

Re: Division by zero?

Posted: Wed Feb 20, 2013 3:56 am
by imsir
If you use kilograms instead of grams you will get this error.

For example if product weights 1540 grams, you shouldn't write 1,54kg but 1540, and choose grams as weight class.