Lee Willis

Region-based shipping with WP e-Commerce

| 328 Comments

I’ve been asked a few times about how to split up countries into regions and charge shipping differently to the different areas in WP E-Commerce. This was something that was almost, but not quite possible with one of my existing plugins.

Now it’s just a little bit easier.

What You’ll Need

In this example we’re going to show how to achieve the following:

  • Set of Weight rates for New Zealand (North Island)
  • Set of Weight rates for New Zealand (South Island)
  • Set of Weight rates for the rest of Asia/Pacific
  • Set of Weight rates for Europe

The Plan

To acheive our end goal we’re going to:

  1. Create 2 regions attached to the country “New Zealand”
  2. Remove New Zealand from the Asia and Pacific continent (So people ordering to NZ see those prices, not the general “Asia and Pacific” pricing
  3. Set up per-country/region rates for New Zealand
  4. Set up per-continent rates for Asia and Pacific, and Europe

Getting Started

The first job is to find out the “country ID” for New Zealand. Using your favourite database you’ll want to look in the wp_wpsc_currency_list table for the entry for New Zealand, and make a note of the value of the “id” field – in our case 156.

While we’re here, we’ll also move New Zealand out of it’s current continent. This basically just involves updating the same record, and setting the continent field to something unique, e.g.

Next – you’ll need to create whatever regions you want in the wp_wpsc_region_tax table, using the ID you’ve just found as the “country_id” field, e.g.

Configuring your pricing

That’s all with the scary database stuff, now on to the easy stuff. First of all you’ll need to activate both of the shipping modules:

First up we’ll configure the continent-based pricing. Click on “Edit” next to the weight-continent pricing. Up will pop the configuration pane, with a drop-down of the standard continents – and also our “newzealand” continent – which we’re not going to use since New Zealand is going to be priced by region.

Let’s pick Europe, and configure some weight rates.

In this case we’ve just configured one weight band – which means that anything shipped to Europe will be charged at the same rate – £80 in this case.

We can do the same for Asia and Pacific, except maybe setting up multiple layers using the “Add Layer” link.

At this stage shipping will work for Europe, Asia and Pacific, but not for New Zealand (Since we took it out of Asia and Pacific).

Click on “Edit” next to the Weight / Country and Region pricing. Up will pop the configuration pane, with a drop-down of the countries, including regions where configured – for example, we can see our North Island, and South Island regions here:

Selecting a region gives us the chance to configure weight rates, e.g.

Repeat for other regions, and you’re set. Happy Shipping!

Note: All weights should be set up in lbs, no matter what weight unit you used to set the weight for your products. WP e-Commerce will convert between them for you.

328 Comments

  1. Hi Lee. I had posted a request in September for zip-code based shipping and you suggested that we custom code our solution. We’ve customized your WP E-Commerce Skeleton Shipping Method plugin to calculate the shipping rates based on the product selected and the shipping zip code; it works great! We also customized the plugin and saved it as a different file for a $0 shipping amount when the customer picks the product up at our warehouse. The customer can calculate shipping by entering the state and zip code and pressing the calculate button.

    Is there a way to for WP e-commerce to force the customer to calculate and include shipping or select warehouse pickup before submitting payment? I’m concerned that they can add a product to the cart, designate the shipping state but NOT press ‘calculate’ so they can checkout with paypal without shipping added to the order.

    The site is http://triccover.com/store.

    Thanks for your help. If you need more info, you can send me mail at mike@meshbiz[dot].com.

    • Hi,

      It looks like it’s a bug in your custom shipping module. It’s returning a price of $0.00 before the user has chosen a state/region. You should modify it so that if it’s unable to calculate a quote it should return an empty array, e.g. Array(). That way when the customers reach checkout they’ll have the “Pickup option”, but there won’t be a “Shipped” option until they choose a state and Calculate.

  2. Hi Lee,

    sorry my english.. I am from Chile…

    I have to configurate too many “weight rates” for too many “regions”…i have definition in Excel…and i want to load directly to MySQL (avoiding typeit)

    in which table do that???

    Thanks

  3. Hi Lee..
    I saw Marta’s message with the OK answer .

    thanks again

  4. Hi Lee..

    quite green in using wordpress and html codes, pardon me for any ignorance..

    I hope to allow users of my website to select shipping based on country/continent/weight, instead of waiting for my email reply.

    so I’m wondering if it is possible to change the preset continents (Africa, South America, Europe etc.)to 4 zone areas/Continents instead
    i.e. I would have to rename to Singapore, Zone 1, Zone 2 and Zone 3 for the different groups of countries?

    fyi, my weight table layers is based on local rates and overseas postage rates -Airmail rates at http://www.singpost.com/send-documentparcel/postage-rates.html

    For example i hope to achieve at checkout, user can choose their country to calculate total cart weight + shipping charges:
    e.g. When user select Singapore – 1 set of weight layers
    Zone 1 – Zone 1 fixed set of weight layers
    Zone 2 – Zone 2 fixed set of weight layers
    Zone 3 – Zone 2 fixed set of weight layers

    Is this possible with your plugin? If yes, pls kindly advise me on what to do and exactly where to change the codes…

    pls reply to my email asap, if possible. appreciate deeply! =)

    • sorry wrong example i just realised…pls ignore..at checkout user will still be selecting their country, not by zone..sorry :P

      rather what i want to achieve is:
      1) to change the continent assigned for each country to my specified zones in the backend, so that i may assign the appropriate weight layers according to the zones

      2)be able to reflect the new zones on the option at the wp shipping interface when weight continent module selected so that i may update the weight layers according to my country’s airmail rates.

      is it possible? thanks!

      • You can do that yes, but you’ll have to make the continent changes directly yourself in the database, in the wp_wpsc_currency_list table I believe. Any changes you make there will be automatically picked up in the weight/continent config as you suggested in option (2).

        An alternative solution would be to use this:
        http://plugins.leewillis.co.uk/store/plugins/wp-e-commerce-premium-shipping/

        That will let you set up weight rates for “Singapore only”, and then to set a separate set of weight rates for “Zone 1″, and let you choose which countries are in that zone etc.

  5. Hi Lee,
    Just saw the video for your premium shipping plugin.
    Looks impressive!

    Just one question:
    Is it possible to do free shipping on orders over $100 (only for Australia).

    I know that I can go in and create it with Order Value.
    But the client would then have to choose this, wouldn’t he/she? (‘Free shipping on orders over $100′)
    Or can the plugin go in and calculate weight based on orders over $100 and then Order Value on orders over $100? (So I just have a ‘shipping Australia’, which calculates on weight, but over $100 it switches to Order Value)

  6. Hi Lee

    Hopefully you can advise where I’m going wrong but having installed your plugin and set up weight rates and setting the weight/continent shipping option to “Single quote for total cart weight”, I am finding that its not adding up the weight of each item in the cart, its simply taking the heaviest item in the cart and using that weight to set the shipping. Regardless of whether I have 1 item or 100 of the same items in the cart, it always gives me the shipping for the one item.

    I’m running WP 3.2.1, WPEC 3.8.7.1 and your plugin version 4.4. Any ideas?

    thanks
    Chris

    • Sorry, it was the lbs / grams issue, what confused me is that for a single item it did seem to be calculating it correctly say at my third postage level which is anything over 250gm, even though the item obviously wasnt anywhere near 250lbs!

      Anyway all sorted, thanks for the great plugin.

  7. Lee,

    Here’s my situation:

    We need to charge a certain set of weight rates for:

    1. the 50 US states.

    2. Canada and Mexico

    3. The rest of the world.

    Can you give me insight on how this can best be accomplished?

    • Set the US State bands up against the USA, Canada/Mexico rates against Canada, Canada/Mexico rates against Mexico, and then for the “Rest of the World” – you’ll have to set the rates against each of the other continents.

    • Hi Rob

      I’ve just done almost exactly that for a site I’m developing, but with UK, Europe and rest of world shipping rates.

      The way I did it was pretty much how Lee describes above but only using the continent shipping option. I then went into the database, changed UK countries from “Europe” to “UK”, then changed all the other countries other than UK and Europe to “restofworld” using a find and replace mySQL script in PHPMyAdmin, for example to replace “Asia” with “restofworld”

      In your case you’d set the USA country to a continent of say “USA” rather than NorthAmerica, then leave Mexico and Canada as northamerica and change every other country to continent code “restofworld”, which then gives you the three distinct “continents” to set weight rates for in the admin area.

      The alternative without running the find/replace script is to do the same to differentiate the USA, then change Canada and Mexico to something unique (say “otherNA”) then set up all the other continents with the same weight rates, but obviously you then need to do it 5 or 6 times for each continent, so it’s more of an ongoing admin overhead.

      Chris

  8. Here’s an idea that might be helpful:

    You could perhaps have these rates work IN ADDITION to the standard weight rates, so that the default WPEC rates are used unless rates are defined through this plugin. That would make my job really easy in this instance, I would have just setup my default rate, then rates for USA, Mexico and Canada.

    Of course, I could be mistaken and it already works like that! Let me know.

  9. Ah, I think I’m all set then. Lee, could I set things up how I’ve described by setting the default weight rate to my “rest of the world” rates, then setup specific tables for the USA, Mexico and Canada?

    I’ve just discovered your Premium Shipping plugin – I think I’ll buy that one as well for a different project. I’d suggest linking to it on any shipping related posts to boost your sales perhaps. Thank you for all that you do to make WPEC better Lee!

    • Ah, I think I’m all set then. Lee, could I set things up how I’ve described by setting the default weight rate to my “rest of the world” rates, then setup specific tables for the USA, Mexico and Canada?

      You can, but customers in the USA, Mexico and Canada will see both rates to choose from (The country-specific ones) and the default weight-rate one…

  10. Rob, did you see my alternative above, I think that gives you what you need just from the one plugin?

  11. Okay looks like I’m all set, thank you Chris, and of course – thank you Lee! One last question for now. I’m only using one shipping option. So The message to choose a shipping method is not needed. I see where I can change the title of the shipping method, but how can I get rid of the “- Choose a Shipping Rate” text.

    For those wanting to change the shipping option title, it’s right here on line 55 of wp-e-commerce-weight-continent-shipping.php -

    $this->name = “Weight / Continent Shipping”;

  12. For info here’s the MySql query I ran to change all the continent entries, just change “africa” to the other continents one by one until they’re all replaced

    SELECT * FROM `wp_wpsc_currency_list` WHERE `continent` LIKE ‘%africa%’
    UPDATE `wp_wpsc_currency_list` SET `continent` = replace(continent, ‘africa’, ‘rest_of_world’)

    If anyone uses it, obviously backup the database before running it, just in case!

  13. Hi Lee – I have used this plugin multiple times now, and I absolutely love it. I wont use any other e-commerce plugin! I installed the premium shipping plugin to extend my shipping options – for whatever reason, the shipping info is not showing up in the paypal transaction log. I need this info to be sent to paypal in order for the fulfillment company to be able to access this info. Any advice would be incredibly helpful. Thanks!

    • As far as I’m aware there’s no way to pass a shipping description to PayPal and have it show up there. The chosen shipping method should be displayed in the WP e-Commerce sales log.

  14. Hi,

    Great plugin!

    I run my store in French and I’d like to translate some strings (like “Weight / Continent Shipping-” on the chekout page for example).

    I’ve installed the CodeStylling Localization plugin to find the strings I want to translate it doesn’t find ant .po or .mo files.

    So I guess I have to change the code itself to achieve what I want, am I right?

    Also, I’ll launch the english version of my site soon so it’ll be multilingual. I will have to make this plugin translatable. Is this a feature you’re thinking about or not? In the last case, would you be able to do it for $$$$?

    Thank you,

  15. Thanks.

    I’ll buy the premium one.

  16. Hi

    Thanks for the great plugin. I’m currently using the free version, but may upgrade to the premium in order to be able to restrict the free shipping over x.xx order value to only the local geographical region.

    Just a couple of questions I wanted to ask, both of the free & premium versions – I’ve done as you suggest in this article, so have both ‘by region’ and ‘by contintent’ enabled, with my local UK split into two regions, and the UK moved out of Europe, with rates set for the two UK regions, and all the continents.

    As far as the website visitor is concerned there is no choice as to which shipping calculation method they will use, so why does the website prompt them to select the only one available? I can see why this would be there for when there is a choice, but surely there’s no need for the radio button if there is only one choice?

    Secondly, surely if someone is going to combine the two (by region & by continent) as I have and as you suggest here, shouldn’t the plugin try each country/region first, then automatically switch to the continent if nothing is defined for the county/region? This would prevent the need to ‘hack’ (as some would call it) the database tables to remove the UK from Europe, or in your example, New Zealand from Asia Pacific.

    I presume as your instructions tell us to do this, it won’t work as expected if we don’t, so presumably the by continent shipping fee would apply even for countries which have explicit shipping fees defined, or would the two fees be combined in this case (I haven’t tried it myself)?

    Thanks.

    • As far as the website visitor is concerned there is no choice as to which shipping calculation method they will use, so why does the website prompt them to select the only one available? I can see why this would be there for when there is a choice, but surely there’s no need for the radio button if there is only one choice?

      That’s handled by WP e-Commerce itself, not the shipping plugin. If you wanted to, you could amend your theme file not to show this as a radio button. The file to change would be wpsc-shopping_cart_page.php.

      presumably the by continent shipping fee would apply even for countries which have explicit shipping fees defined, or would the two fees be combined in this case (I haven’t tried it myself)?

      The user would see both shipping methods and would be able to choose one or the other.

Leave a Reply

Required fields are marked *.

*