Lets say I want to check what shipping methods are available (before customer sees the shipping methods) and want to enable one if certain conditions exist.

  • What event would I be observing
  • What method calls do I need:

    1. To see what shipping methods are enabled
    2. To enable a given shipping method

Magento shipping method is depends on shipping address . first load quote shipping address then get shipping method from shipping address and code should like this

 $quoteShippingAddress = $quote->getShippingAddress();
        if(!is_null($quoteShippingAddress->getId()) ) {

     $groupedRates = $quoteShippingAddress->getGroupedAllShippingRates();
            $ratesResult = array();
            foreach ($groupedRates as $carrierCode => $rates ) {
                $carrierName = $carrierCode;
                if (!is_null(Mage::getStoreConfig('carriers/'.$carrierCode.'/title'))) {
                    $carrierName = Mage::getStoreConfig('carriers/'.$carrierCode.'/title');

                foreach ($rates as $rate) {
                    $rateItem = $this->_getAttributes($rate, "quote_shipping_rate");
                    $rateItem['carrierName'] = $carrierName;
                    $ratesResult[] = $rateItem;


$result is give shipping method list

2.As amasty say,shipping method are enabled from admin.Also you can do this by programmatically:

  1. foreach (Mage::getSingleton('shipping/config')->getAllCarriers() as $k => $carrier) {
        if ($carrier->isTrackingAvailable()) { // or your custom condition
            $options[] = array(
                'value' => $k,
                'label' => $carrier->getConfigData('title'),
  2. To enable shipping methods you can update the config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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