I have various shipping methods configured and would like to select a default one based on country of the visitor or something.

For example if the user is from Spain (Or spanish Locale) then default shipping is ... and if from another country then International shipping.

Can anybody help me out here? I don't have a clue where to start.

Also I want it to be applied by default, because we have an PayPal express checkout and if I click on it without entering the cart and selecting the Shipping method from the Estimate section, the shipping cost's are not applied when Paying by PayPal... This is a problem..


1 Answer 1


You need to create your custom shipping method.

To do so, create a custom class extended from Mage_Shipping_Model_Carrier_Abstract, and start writing your business logic code inside overloaded collectRates method.

class Arturas_CountryBasedShipping_Model_Shipping_Carrier_ShippingMethod extends Mage_Shipping_Model_Carrier_Abstract {

    protected $_code = 'countrybasedshipping';

    public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
        // skip if not enabled
        if( !Mage::getStoreConfig( 'carriers/' . $this->_code . '/active' ) ) {
            return false;

        // Fetching a country based price
        $cb_price = $this->getCountryShippingPrice( $request->getDestCountryId() );

        $result   = Mage::getModel('shipping/rate_result');
        $method   = Mage::getModel('shipping/rate_result_method');

        $method->setMethodTitle('Contry Based Shipping');


        return $result;

You also may want to read this article.

  • Hello, sorry for the late reply. Is it posible to assign auto shipping method from the one that I have in the configuration? The problem is that we have other modules (provided by the shipping company) and I would like to assign one of those as default. I tryed using this extension: magentocommerce.com/magento-connect/auto-shipping-pro.html but it doesn't work.. I don't know why, no errors nothing..
    – Artur Rain
    Nov 24, 2014 at 12:15
  • Sure. Use setMethod method with code of your preferred shipping method. Nov 26, 2014 at 6:49
  • Could you please mark it as accepted (if it's been accepted of course) Apr 16, 2015 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.