PDA

View Full Version : FIX: micro Gram g Shipping Weight in .lbs Problem



michael_s
02-22-2010, 11:00 PM
1) IMPROVE ACCURACY OF SHIPPING WEIGHTS:
2) FIXES: Calculation failures resulting in 0.00 .lb totals when products weight is based in sub-gram weights.

This FIX might be needed if you sell commodities in bulk weights starting in small units such as grams.

Please note: Your individual Store's implementation my not require this extreme low weight precision, as does my client’s.
IF YOU DON'T KNOW MySQL via phpMyAdmin, or computational mathematics... Don't bother yourself with this fix/mod. This is a minor bug issue. Conversely, this exercise might well help you understand the shipping modules functionality.

No fault here of osC3 --- weights can be calculated to infinite precision, but to get a final real world "REPRESENTATIVE" value, we need to restrict the place values of the decimal place between the various weight class conversions. So some might see this contribution's-contribution, as OVERKILL in parts or in the whole, but ....

Test for yourself, create a single test product with a weight of .3 grams, then try to buy 3000 of the product... You won't be able to get a weight calculation at all.

If the shipper's default unit is .lbs. (i.e US), while a customer buys a quantity of 3000 with each product weight being .001 grams, the end weight conversion by osC3 always will be converted to 0.00 lbs. or as I've found 0.00000000000000000000 .lbs... meaning no weight at all, when there is actually a weight in the real world....So, THIS IS BY NO MEANS CORRECT.

.4 grams turns into 0.000881849 .lbs BUT, with the default precision of os3, the shipping weight conversion equals .00 lbs as a starting product weight. So if I have a quantity of 10,000 parts X .4g per part, the total should be 4000g or converted to 8.818490487 lb. BUUUUUT, os3 does the conversion first, if the shipping weight is defaulted to pounds... so it calculates a quantity of 10,000 x 0.00 .lbs equaling ZERO instead of the 8.82 lbs that it should be.

My Solution: osC3's Default precision is problematic, rather than 2, to be safe, for my implementation, I need the precision set to 10... with wider floating point ranges.

Feel free to correct this contribution as needed.

More... (http://addons.oscommerce.com/info/7256)