Search code examples
magentorestriction

How to restrict other shipping methods - Magento


By $result = Mage::getModel('shipping/rate_result'); method I can create a new shipping rate. But How can I restrict other shipping methods in this action?


Solution

  • Grab All active shipping methods, loop through each one, and see if it matches your desired one

    $activeCarriers = Mage::getModel('shipping/config')->getActiveCarriers();
    foreach($activeCarriers as $code => $method) {
        if($code == 'yourcode') {
             $result = Mage::getModel('shipping/rate_result');
        }
    
    }