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.
Section:
| Attachment | Size |
|---|---|
| 6.42 KB |



Comments
thanks
Thanks for posting this information. I used your include example as a basis for my own little shipping calculator. In my calculator the price is affected by the quantity of each item. Example: A quantity of 1 is shipped for $2.25, a quantity of 2 for $4, and so on. Made easier because there's only one item in the store.
Developers should know that the $txn object holds all the information on the order. Not sure where you could go to see all the different values available.
BTW: You're posting is fourth on Google searches for "Drupal ecommerce shipping." I wouldn't have known about this otherwise.
your comment form math
your comment form math question isn't working right. I just guessed it was one less than the answer...
Great stuff!! Thank you!
Great stuff!! Thank you!
Hi! I want to ask how to
Hi!
I want to ask how to extrapolate the quantity information from the $txn variable.
With this information we can count 2 pieces of the identical item as the first and the second item of the shipping cost, meanwhile now 2 pieces of one item are calculated as 1 item shipment.
Thank you!!!
Pablo
Canadian taxes in e-commerce
Hello,
Can I asked how you solved the canadian taxes issue within e-commerce? I've just been handed the task to review the Canadian taxes and I'm having a hard time knowing where to start.
Switched to Ubercart
We've recently migrated this site to using Ubercart, so can't even look at what we did to resolve this problem with eCommerce. Sorry.
Add new comment