1and1 Help Centre Categories

print article

How do I calculate shipping fee based on the Country of Delivery

First you will have to do the following:

Under 'Settings' -> 'Advanced Settings' -> 'Basic Setting' -> 'Other shop
settings'
you will find Swap the first and second pages of the order process? Choose Yes.

The second order step (address entry) will be displayed before the first one
(select delivery and payment method).

Thus you can access the country given by the customer in a rule for the first order
step (which is now displayed as the second one).

Now enter the following code under 'Settings' -> 'Advanced Settings' -> 'Payment methods' -> 'Settings for all payment methods'Here you should see 'Rule for all payment methods':


if (get_orderinfo_shipping_field("country"))
$country= get_orderinfo_shipping_field("country");
else
$country= get_orderinfo_field("country");

if ($country == "UK")
$shipping_fee= 8.95;
elseif (strstr("CA MX FR", $country))
$shipping_fee= 14.95;
elseif (strstr("IN SG MY", $country))
$shipping_fee= 29.95;
else
$shipping_fee= 40.00;
Note: strstr function finds the first occurrence of a string. So in this
case, CA, MX and FR will have a shipping cost of 14.95

You can find the country codes at: 'Settings' -> 'Advanced Settings' -> 'Text modules 1' -> 'Texts for the country, state, and province lists' Here you can see 'List of countries for country selection'

Please note:
Please note that the option 'Customer number required?' will not be observed in the
wizard for payment methods if 'Swap first and second order pages?' has been
selected. You can use this to limit the use of a particular payment method to
registered customers.

If 'Swap first and second order pages?' has been selected, then an entry must be
made in the Country field, otherwise the tax area cannot automatically be selected
on the following page.

Please note that this rule will cause an error message if you cancel swapping the
first and second order pages.