Simple shipping and some other stuff - 5.0

Events happening in the community are now at Drupal community events on www.drupal.org.
sime's picture

Howdy

I finally got around to writing some simple shipping (ie. with no external apis) code for E-Commerce 4.7. I had intended to do this for a while, but was always held back by the fact that it had to involve changes to store and address modules.

I have just now had the time to do a preferred solution. It is not going into E-Commerce 4.7, because I've made extensive changes to core modules. However, if there are no major complaints, I have semi-permission from gordon to build this into head (soon to be 5.0).

So let's start with the changes to non-shipping:

  • Changed store_build_states() and store_build_countries() so that it checks for the installation of location.module. In this way, multiple country states are supported.
  • Moved the huge state and country lists out of store.module, and changed the state function so that you can hard-code states from multiple countries. In this way, if you don't want to use location.module, but you want multi-country support, you don't have to hack store.module directly (i.e. the hack is less severe).
  • Additional settings for store module, allowing you to choose a "store location country" for example. Also a choice to choose KGS over LBS, for example. I didn't go crazy on this, just a step in the right direction. ;-)
  • Changes to address.module, so that when you select the country, a drop-down state box for all of the configured countries. So, in Australia I might have state selection boxes for Aust and New Zealand, but for everything else the user just types it in. This helps collection valid state codes for shipping calculation.

Now for simple shipping

  • Once you have configured countries and states. You can also configure regions, say Region 1, Region 2, Region 3 and No Delivery
  • For each region you specify things like "base charge", "cost per kg/lb", etc
  • You then assign countries and states to each region. The interface is an intuitive option button design.
  • In the checkout, once the address is established, the user's Region can be determined. So if the user belongs to one of your target countries, their state will be used to determine the Region
  • Then, the shipping calculation will use the appropriate regional settings.

The decision to make simple shipping a partner of shipcalc was partly because that made the problem easier to approach. I recognise that shipcalc was built for interfacing external APIs, and I'm not arguing again this - just I believe what I've done is a smooth and constructive way forward.

It won't be hard to work this into 5.0. I have a 4.7 demo and regular contributors can contact me directly for temporary admin access. Also to see the actual code changes.

Thanks
Simon

Comments

Excuse me, I'm a little

lucyconnuk's picture

Excuse me, I'm a little confused because I've been up since 4am, but do you mean that you DO have a 4.7 version of simple shipping or only a 5.0 version?

If you have a 4.7 version, please, please could I have a copy?

I have been desperately trying to get some simple shipping working for a big site that's going to be live in the next couple of weeks, but I've done something wrong (I don't really understand hooks etc, I wouldn't be fiddling with this stuff at all if there was any kind of simple shipping available for the UK.) Somewhere along the line things stopped working and now only half of my products have an entry in ec_shipping_product and the rest just ignore shipping completely!

Enough of the sob story - can you help me?

Lucy

Sorry, no it won't work with

sime's picture

Sorry, no it won't work with default E-Commerce 4.7.

There are some shipping partner files for shipcalc that might help: http://drupal.org/node/71718

one for nedjo

sime's picture

Nedjo, I need you to double-check one change to the shipcalc.module itself: I want the partners to receive the validate/submit callbacks directly, since each partner has a separate settings page anyway. The reason for this is that I had to retheme my settings form, and it is not possible to do this the way it is set up now.

So on line 170 from:
return drupal_get_form($shipcalc_settings_form' , $form);
to:
return drupal_get_form($partner .'_shipcalc_settings_form' , $form);

I will need to update the UPS, USPS and Canadapost partners to reflect this change and accept the submit/validate callbacks directly. Otherwise, it's not a huge change, AFAIK.

Makes sense

nedjo's picture

shouldn't cause any problem. Thanks for your work on the code.

Cheers, thanks for having a

sime's picture

Cheers, thanks for having a look

Please see here for new

sime's picture

Please see here for new flexicharge features (including simple shipping), now in dev version of 4.7v3 and 5v3.
http://drupal.org/node/122769

There are instruction there too for creating custom .inc files.

e-Commerce Module

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: