Jeffrey L. Roberts
Jeffrey L. Roberts

Reputation: 2994

Disable shipping in Magento to a specific country in all stores except one

We would like to disable shipping to the UK from all of our store views except for the .co.uk store view...

I have created my own custom shipping module following the guides on http://techportal.inviqa.com/2011/06/09/creating-a-custom-magento-shipping-method/ and http://www.magentocommerce.com/wiki/5_-_modules_and_development/shipping/create-shipping-method-module

As you can see, in both of the above links, there is an xml block that states whether or not to allow all countries, or specific countries

<sallowspecific>0</sallowspecific>

The description of the above block follows

sallowspecific  set to 1 to limit the countries the rate is applicable to

I could really use an example of what the config.xml should look like with sallowspecific set to 1

Any input is greatly appreciated!

Thank you!

Jeff

Upvotes: 3

Views: 9239

Answers (2)

Jake A. Smith
Jake A. Smith

Reputation: 2328

There is a configuration option that sets what countries you allow. By default, all countries are selected. You can modify this as low as the store view level to remove the UK store. You can find it here:

System -> Configuration -> General -> General -> Countries Options -> Allow Countries

If there are going to be multiple cases like this, I would suggest disabling UK and any other countries at a global level and then enabling the countries you want on a per store / store view level. This should help you manage most of your store views without having to update every single one by hand.

Upvotes: 4

MagePal Extensions
MagePal Extensions

Reputation: 17656

These line of codes will only set the default value for your module if they are not set by the user after install

<default>
    <carriers>
        <shippingName>
            <sallowspecific>0</sallowspecific>

When sallowspecific is set to 0 it will enable your country selector so you can select which country you want to ship to, to get a better understanding of how this work take a look at 'Flat Rate' and change the option for 'Ship to Applicable Countries' and take a look at what happen to 'Ship to Specific Countries'.

This is what the 1 and 0 set

 <select id="carriers_flatrate_sallowspecific" name="groups[flatrate][fields][sallowspecific][value]" class="shipping-applicable-country select">
     <option value="0" selected="selected">All Allowed Countries</option>
     <option value="1">Specific Countries</option>
 </select>

If sallowspecific was set to 1 then your default should look like

<default>
    <carriers>
        <shippingName>
            <sallowspecific>0</sallowspecific>
            <specificcountry>US,GB</specificcountry>

In your system.xml you need to have

   <sallowspecific translate="label">
        <label>Ship to Applicable Countries</label>
        <frontend_type>select</frontend_type>
        <sort_order>90</sort_order>
        <frontend_class>shipping-applicable-country</frontend_class>
        <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
    </sallowspecific>
    <specificcountry translate="label">
        <label>Ship to Specific Countries</label>
        <frontend_type>multiselect</frontend_type>
        <sort_order>91</sort_order>
        <source_model>adminhtml/system_config_source_country</source_model>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
        <can_be_empty>1</can_be_empty>
    </specificcountry>

Then go to each store view and select the applicable countries.

Upvotes: 2

Related Questions