sKunKbad Posted October 19, 2009 Share Posted October 19, 2009 I'm making my own ecommerce application, and have integrated a function to get shipping rates from UPS. This function has a few parameters, of which include a package height, width, and length. It would be moderately easy to calculate size if all products were the same size, but that is almost never the case. So, I'm wondering how other sites handle this. My initial though was to include a field in the product database for cubic size, but this wouldn't work because some products/packages which are quite long would have an extra fee. Actually, the price of shipping is more based on weight for average sized packages, so I may be able to set the parameters to match a "standard" size package. Any advice? Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/ Share on other sites More sharing options...
cags Posted October 19, 2009 Share Posted October 19, 2009 There was another question about this very recently. I believe the conclusion was put forward by Daniel0 that it requires some fairly advanced maths. I'm sure if you search the forums you could find that any other threads relating to the topic. Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-939948 Share on other sites More sharing options...
sKunKbad Posted October 20, 2009 Author Share Posted October 20, 2009 I tried searching around for "shipping", "package", and "dimensions" but couldn't find the thread/post you are referring to. Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-940582 Share on other sites More sharing options...
cags Posted October 20, 2009 Share Posted October 20, 2009 Hmm.. I just looked, I couldn't find it at first, then I remembered what he called the problem and searched for knapsack, I think this was the thread. I should explain there is no solution there but Daniel0 did link to an explanation of the problem on wikipedia. Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-940585 Share on other sites More sharing options...
FeralReason Posted October 20, 2009 Share Posted October 20, 2009 I'm assuming the products to be packed vary in size -- possibly in all 3 dimensions. I think the math will be fairly complex. I managed a project (all programming done by a contractor) for a robotic system to build pallets of a certain size from magazine bundles which only varied by height. This required a very complex algorithm which never worked quite right. The advantage you have is you know all product sizes before sizing your box (whereas the system I refer to had to make a real-time decision based on a limited look-ahead of product sizes.) However, if your products vary in size in all 3 dimensions, this may be much more work than you want to do. There may be code you can buy to do this but, for the site I'm working on, I decided this was a bridge too far. I am using USPS -- shipping cost more dependent on weight and distance -- so I decided not to pursue this. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-940597 Share on other sites More sharing options...
sKunKbad Posted October 21, 2009 Author Share Posted October 21, 2009 I agree that since shipping is mostly based on weight and distance, we can probably forget about the dimensions. After sitting and trying to figure out a solution, the best I could come up with was to base it on a cubic dimension equivalent, and make an educated guess... Putting this aside, something a little more important to figure out is if somebody orders enough items to go over the weight limit for UPS, which I think is 80 pounds. Oh the joys of building an ecommerce application! Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-940929 Share on other sites More sharing options...
angelcool Posted October 26, 2009 Share Posted October 26, 2009 Hi there, I am having the same dilemma, I have been developing an e-commerce site and I am facing the same problem. So far, I came up with the following logic: 1.- Add the following columns in the products table in database: a) weight b) dimensions c)group-able(true/false, this is if item's size is big enough to be shipped by itself) 2.- Once the shopper has added all items in cart, determine all items that are NOT group-able and get its shipping cost from UPS based on the given destination ZIP code. 3.- Create an imaginary cube combining all group-able items weight and dimensions, and get its shipping cost from UPS based on the given destination ZIP code. 4.- If weight in step 3 is over 80 pounds split the imaginary cube's size and weight into 2 imaginary cubes; 5.- Add shipping costs: all non group-able items + imaginary cubes 6.- Add total shipping cost to cart. Perhaps not perfect, this logic sounds correct to me. I have not implemented it on my site yet, but eventually I will; if you want to preview my shopping cart go to: 71.160.31.176 (dynamic). Angel Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-944787 Share on other sites More sharing options...
sKunKbad Posted October 26, 2009 Author Share Posted October 26, 2009 Hi there, I am having the same dilemma, I have been developing an e-commerce site and I am facing the same problem. So far, I came up with the following logic: 1.- Add the following columns in the products table in database: a) weight b) dimensions c)group-able(true/false, this is if item's size is big enough to be shipped by itself) 2.- Once the shopper has added all items in cart, determine all items that are NOT group-able and get its shipping cost from UPS based on the given destination ZIP code. 3.- Create an imaginary cube combining all group-able items weight and dimensions, and get its shipping cost from UPS based on the given destination ZIP code. 4.- If weight in step 3 is over 80 pounds split the imaginary cube's size and weight into 2 imaginary cubes; 5.- Add shipping costs: all non group-able items + imaginary cubes 6.- Add total shipping cost to cart. Perhaps not perfect, this logic sounds correct to me. I have not implemented it on my site yet, but eventually I will; if you want to preview my shopping cart go to: 71.160.31.176 (dynamic). Angel This sounds complex! Right now, the request from UPS alone seems to take a long time. I can imagine that what you are doing makes it a much longer wait for the user. I just decided to skip it. It should be acceptable for packages to be in a range of prices, and because handling charges need to be applied, the rate given to the user is not exactly what UPS charges (the way I made it). I think it is something that will need to be fine tuned. You win some you lose some... Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-944955 Share on other sites More sharing options...
angelcool Posted October 26, 2009 Share Posted October 26, 2009 Yes, time is big issue; go to http://71.160.31.176/old/ups/upsRate.php I am looping 4 times through ups server, as you can see takes few seconds to loop, I also agree handling charges may also be added to shipping cost. However, internet is super duper competitive, forcing companies to wave handling fees and some times shipping costs, I am adding an option to manipulate this through the back end to drive customers in; of course, always doing the math to keep a profit margin. Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-945050 Share on other sites More sharing options...
sKunKbad Posted October 27, 2009 Author Share Posted October 27, 2009 You are definitely right about the web being a competitive marketplace. Did you ever successfully develop ideas based on the shared logic? Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-945180 Share on other sites More sharing options...
FeralReason Posted November 6, 2009 Share Posted November 6, 2009 Angel -- I like your logic. Let us know if you are able to acomplish step 3 and get reasonable results ! Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-952626 Share on other sites More sharing options...
jaywebguy Posted November 10, 2009 Share Posted November 10, 2009 Ok, I had to sign up to put in my two bits. I look up shipping cost based on weight of the product. In the admin section of our site, the manager specifies the average package weight, then when figuring shipping the number of packages is broken out by the total weight divided by the set average weight. I think right now we have it set to 40 lbs, so if the total order was 50lbs, we would pass to ups two packages for the shipping quote, 1 at 40lbs, the other at 10lbs. This has worked out well. About once a year we query from our world ship program (ups) what our average package weight was, then adjust the weight in the admin section. We also added a field in the product admin area for a additional freight charge (doesn't show up for the customers), its used for bulky items, that would require additional charges from ups. There are many ways to handle the shipping though, but trying to calculate the size of the box, is a pretty lofty goal. Good luck Jason Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-955280 Share on other sites More sharing options...
angelcool Posted November 12, 2009 Share Posted November 12, 2009 Sorry I couldn't reply any sooner, I had some issues with my win box. Although, I have laid out the logic to calculate shipping costs, I haven't had any spare time to write it; I just had midterms and I'm looking forward to get it started once out of college for winter break. In the admin section of our site, the manager specifies the average package weight, then when figuring shipping the number of packages is broken out by the total weight divided by the set average weight. I think right now we have it set to 40 lbs, so if the total order was 50lbs, we would pass to ups two packages for the shipping quote, 1 at 40lbs, the other at 10lbs. This has worked out well. Jason, would you have a test (or live ) cart for this ? I will really appreciate it. Angel Quote Link to comment https://forums.phpfreaks.com/topic/178265-calculating-a-shipping-package-size-based-on-cart-contents/#findComment-956453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.