13 replies [Last post]
the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Was this information Helpful?

First question:

I'm currently using OSC for my store and have hacked up a USPS and UPS shipping module to allow me to accomplish the following for USPS dimensional weight shipping quotes. I never did get time to post my code for the OSC community.

Each item in the catelog get its own dimensions (item only) and weight.

Using the dimension of the item I can then estimate the size of the box needed to hold multi item orders and get an accurate quote.

I have a screen in OSC where I can define my boxes on hand, their dimensions, and their max weight. I also define what order the 'fit routine' tries to pick a box. So it tries the small box first and if the total item dimensions are too big it goes to the next sized box. If the order can't fit in one box it splits the order into 2 boxes and quotes correctly for multi boxes.

My question is, does this type of module exist for USPS shipping quotes in Ubercart?

My plan is to port my OSC store to Ubercart in the near future. The above shipping quote feature is something I must have before I can go live with the Ubercart store.

The quote system needs to be accurate (no artifical padding after the quote comes from USPS) for both domestic and international.

Second question:

Is there a module to add weight attributes to product options (eg blue one weighs 2oz more than the red one)?

the_canuck
www.canuckengineering.com

jantoine's picture
Offline
Bug Finder
Joined: 05/02/2008
Juice: 167
Packaging module

Hi the_canuck,

To address your first question, I don't believe that Ubercart has a packaging module that actually takes the dimensions of all products a customer is purchasing and tries to pack them into a list of pre-defined packages. I need a similar module and am interested in the code you have written. A "packaging" module could be written that all shipping modules could call. The shipping modules can pass a list of products and a list of pre-defined packages to the module. The packaging module would then return a list of packages including weight and dimensions along with what products ended up in what package. I was also thinking about letting store administrators specify how much room to leave for packing materials. Other ideas are welcome.

As for your second question, after adding attributes to products, when configuring attribute options, you are able to specify an additional cost, price, and weight for each attribute option. As far as the packaging module goes, we would also need to be able to specify additional dimensions.

Let me know if you are still interested in this and perhaps one of the Ubercart guru's (Ryan or Lyle) can chime in and let us know what they think, and if something like this is already in the works for Drupal 6?

Cheers,

Jon Antoine
Antoine Solutions
Free Open Source PHP IDE

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
AntoineSolutions wrote: Let
AntoineSolutions wrote:

Let me know if you are still interested in this and perhaps one of the Ubercart guru's (Ryan or Lyle) can chime in and let us know what they think, and if something like this is already in the works for Drupal 6?

Yes, I'm still interested. I hope to get time to redo my website and store over the Christmas break. Well at least get a good chunk of it done.

It definitely seems like a reasonable bit of code to write and would be very useful for many store owners.

My products vary in size and weight dramatically so I can't really do without it unless I want to eat shipping costs over and over.

Andrew

jantoine's picture
Offline
Bug Finder
Joined: 05/02/2008
Juice: 167
FedEx module

Hi Andrew,

After a lot of research, I found this to be a very hard (doctorate level) algorithm to write. Instead of using this solution, I added a feature to the FedEx module that calculates dimensional weight and uses whatever is greater, actual weight or dimensional weight. I then also added an option to break packages by a specified weight. This has given me the best results so far in calculating shipment costs.

Cheers,

Jon Antoine
Antoine Solutions
Free Open Source PHP IDE

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Check you website email

Jon,

I sent you my code from OSC on your website email. It's too long to post here. Hopefully it will bring light on the algorithm. The code has been working in my OSC store for over a year now. It's a big mess but what OSC code isn't.

Andrew

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Code USPS module

Can anyone give advise on how to implement this properly?

I have been working towards getting ready to code.

I have been reading through the Drupal tutorials on creating modules etc. and think I'm ready to go.

Is the right approach to rewrite the USPS contribution and add my functionality? Is there another way to use conditional actions or something else to allow dimensional weight across all shipping modules?

I have a week off and would like to make this happen soon.

I have a coding background, but still learning the Drupal/Ubercart conventions.

I have got my algorithm worked out on paper after reviewing my OSC code. After looking at USPS module I think its possible.

So far what I need is a way to store a list of available boxes in the database with dimensions, max weight etc. I'll need a way to easily add to the list. Everything else that I need appears to be already provided in the standard USPS module.

BTW I'm working with Ubercart 2.0 Beta 3 and Drupal 6.9. Everything so far looks really good. Much better than OSC.

Andrew

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Code!

I'm now well on my way to getting dimensional shipping to work for USPS quotes.

First off, I realised I needed to do alot of modification to the USPS shipping module for Uber2.0beta3

I started out by setting up my own module USPSDW and got it working the same as the original USPS only with new function names, etc.

I then added a table to hold all the available shipping boxes the software can choose from and added
Box id, Box name, Box desc, box cost, box max weight, box empty weight, length, width, and height. I came up with an interface to add/edit/delete boxes from the store admin. Everything seems to work just fine for this section so far.

I added an option to turn off/on the dimensional weight calculations on the shipping module admin page.

I'm in the process off adding fucntions and modifying a couple of the original USPS fuctions. I should be finished with this in a couple days. I'll then start testing.

The algorithm is basically below.

Sort available boxes from smallest to biggest.
Sort products in the order from biggest to smallest
Try to fit biggest product in smallest box.
If it fits subtract volume of product from available volume and go on to next product in order and try to fit it in the same box.
If it doesn't fit move order to the next bigger box and try again.
If you make it to the biggest box and everything won't fit, start over with a second box.

You need to take care of products with no dimensions given. I estimate volume based on weight.
You also need to take care of products that don't fit in the biggest box.
You also need to allow for packaging. Easy to do and only allow 80% of max. volume

The does it fit fuction takes into account volume, and dimensions of the product. For a partially full box I take volume into account as well as the original size of the box being tried.

It's not a perfect solution but will improve the quote given to something realistic and managable. If we were dealing with thousands of products per order there would be a problem with the sorts taking too much time. I'm not too worried since most orders are under 20 different products. I've been using this idea on my OSC store for 3 years now and have gotten very good accurate quotes.

My hacked new module will still have all the functionallity of the original USPS module but with the additional dimensional weight calculator. You can choose to turn on/off the new features.

Once I have the code working reasonably well, is there some person to forward this to for official testing? I don't really have the time to maintain this myself or figure out CVS. The code is really pretty straight forward and I'm documenting with comments as I go. I'm trying to follow the coding conventions outlined by Drupal's development team.

Andrew

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Thread Moved

I moved the thread to the development forum since I guess that's what I am attempting to do.

Andrew

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
Re: USPS shipping (dimensional weight shipping) My Solution!

I'm almost there on the code. With a bit more testing and some on screen help documentation I think its ready to go.

Quotes are coming out as expected with the DW shipping calculator turned.

Andrew

the_canuck's picture
Offline
Joined: 10/08/2008
Juice: 54
My Module!

To install un-enable standard USPS module and enable USPS with Dimensional Weight.

To setup you will need to add a list of your available shipping boxes in the /admin/store/settings/uspsdw_packages screen. Too add new box, hit edit and change ID to a unique number, enter parameters for name, description, length, width, height, empty weight, max weight, and cost.

Currently the cost isn't computed into the quote but that is the original intent. The cost would include the cost of the actual shipping materials to be added to the quote only if that box is chosen by the calculator.

Next you will need to check your catalog of products to make sure they each have dimensions and weight. Without dimensions, the calculator assumes a standard density and makes estimate dimensions. (It will choose the largest box from the list for any products without dimensions.)

Also you will need to set the 'Package type' to 'Not ready to ship' for the calculator to know if the product needs to be packed in a box or not. All the other selections will force the calculator to quote as if it was individually packaged in the package type selected.

Finally you will need to enable the DW calculator in the /admin/store/settings/quotes/methods/uspsdw admin screen. The other 2 selections should work identical to the standard USPS module.

I'd appreciate some feedback if you try it out.

Left to do:
The help screen is not working for the admin/help/uc_uspsdw.
The cost of the box is not yet added to the quote.
Code cleanup.

Andrew

AttachmentSize
uc_uspsdw.zip 14.59 KB
smithn.nc's picture
Offline
Joined: 05/06/2009
Juice: 9
Hello hello, Sorry for

Hello hello,
Sorry for bumping an oldish thread, but I was wondering, was any more work ever done to iron out the kinks mentioned in the most recent post?. Also, is this module still compatible with 2.0 RC3?

mquocle's picture
Offline
Joined: 10/13/2009
Juice: 2
hi the_canuck, Do you still

hi the_canuck,

Do you still have this code for osc for dimensional weight? I am looking for this module a while and across your post. If you can send me email of this code, it will be great.

Thanks

blue.cobalt's picture
Offline
Joined: 11/17/2010
Juice: 8
updated module?

hey the_canuck,

Have you updated this module? The code attached doesn't work in Ubercart 2.4 in Drupal 6.19.

When I go to /admin/store/settings/uspsdw_packages/edit there is no way to add a box.

I could really use this for a project I'm working on.

thanks,
Blue

zkrebs's picture
Offline
Joined: 03/23/2010
Juice: 42
I could

also really use this module, and have a bounty from a client to get this to happen

http://mindfulintegrations.com - Drupal and Ubercart Consulting.