Jump to content

Calculating a shipping package size based on cart contents


sKunKbad

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

 

Link to comment
Share on other sites

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

 

 

 

 

 

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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  :shrug:) cart for this ? I will really appreciate it.

 

Angel

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.