Custom Shipping for Drupal eCommerce

The e-commerce module for drupal allows custom plugins to handle shipping calculations. There are some complex plugins that allow querying of the US and Canadian Post offices for live rates based on the size and weight of packages, etc. etc.

But not everyone needs elaborate shipping tools. There has been a certain amount of complaining on the Drupal forums about the need for simple shipping modules. I had to write a fairly simple such module recently, and found it relatively easy to do.

We re-launched Octopus Books as a Drupal site not so very long ago. Their shipping scheme is quite simple: there's a tiered set of shipping costs for the first, second, and subsequent books, and a Canadian and an International version of each rate. Oh, and some books, marked "heavy" are charged an additional rate, and counted first when calculating shipping.

All that logic lives in a single script, which defines the admin menus, creates additional fields for the items (in this case, a "heavy item" checkbox), and does the shipping calculations.

The code is attached, and the file (named *.inc) is dropped into /modules/ecommerce/contrib/shipcalc/partners/, which makes it available on the ecommerce shipping admin page.



Attachment Size
octopus.inc_.txt 6.42 KB

Add new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.