Creating shipping cost by countries for Drupal Commerce

Shipping to different countries is a very common setup for most e-commece website. In this tutorial, we'll show you how to add shipping cost for certain countries using Commerce Kickstart distribution (though this can apply to the standard Drupal Commerce module, using shipping flat rate and addressfield module). To keep it short and simple, we will create 2 different standard shipping - one for UK and another one for rest of the world.

Let's begin:

1. Go to Menu --> Store Settings --> Shipping (admin path: /admin/commerce/config/shipping)

2. Click on 'add a flat rate service'. Fill out the fields like you see in the the screenshot below

shipping 1

3. Set you own base rate and currency

4. Drupal commerce already has a standard shipping flat rate so we will use that for UK. If you don't have this, repeat 1 to create another standard shipping but keep the Display title the same, ie, 'Standard shipping 3 - 5 days. This is to ensure that when the shipping rate is shown on the cart page, the description is the same to keep it seamless. Only the price should change based on which country is selected.

5. Once you have added the flat rates, you should have something like the screenshot below.

6. Click on 'edit component' for standard rate.

7. Under 'Conditions', click on 'Add OR' and then 'continue' button in the next page.

8. Under 'Conditions', click on 'Add condition'.

9. Select, 'order address component comparsion' in the dropdown list.

10. Under 'Address', select 'shipping information - address' in the dropdown list.

11. Under 'Address component', select 'country'

12. Leave 'operator' as 'equals'.

13. under 'value' textarea, add GB (for United Kingdom) and save the page. It uses ISO country code. You can get a list here: http://www.geoplugin.com/iso3166

14. Finally, drag the anchor for 'Order address component comparison' below the 'Or' and indented and save the page. See screenshot below:

Shipping 3

 

14. For 'Standard rate (rest of the world), repeat no #6 to #13. But the only changes here is to tick the box for 'negate'. This means for any shipping that is not GB, apply this rate.

That is the standard shipping rate done. If you want to add more different  rates based on countries, just repeat adding a new flat rate and then add another country code. You can also target a set of countries, for example all EU countries - just add a list of country code one after the other, like:

EU Countries

AT
BE
BG
HR
DK

and so forth...

This tutorial uses the following modules for Drupal Commerce:

https://www.drupal.org/project/addressfield
https://www.drupal.org/project/commerce_shipping
https://www.drupal.org/project/commerce_flat_rate