0

i'm new to magento. In my custom module I'm getting list of available shipping methods.

Shipping Methods are getting but available shipping services are not getting.

my code is:

<?php

class Easylife_Ship_Model_Cart extends Mage_Checkout_Model_Cart
{
    public function services()
    {

      $servers =  $this->_getCart()->getQuote()->getShippingAddress()->setCountryId('India')
            ->setCity('Hyderabad')->setPostcode('500073')->setRegion('Andhra Pradesh')
            ->setCollectShippingRates(true);
                 //$this->getQuote()->save();
        return $servers;

    }

    protected function _getCart()
    {
        return Mage::getSingleton('checkout/cart');
    }

    public function shpmethods()
    {
        $methods = Mage::getSingleton('shipping/config')->getActiveCarriers();

        $options = array();

        foreach($methods as $_code => $_method)
        {
            if(!$_title = Mage::getStoreConfig("carriers/$_code/title"))
                $_title = $_code;

            $options[] = array('value' => $_code, 'label' => $_title . " ($_code)");
        }


        return $options;
    }

}
  • Are you sure you wanted 'shpmethods()' and not 'shipmethods()'? – user2045 Jun 6 '14 at 17:40
  • @user2045, I want shipmethods().any way I got result of shipmethods()'. Now how can i get available shipping services` based on address. – Magento Nav Jun 7 '14 at 6:01
  • I just happened to notice that you misspelled shipmethods in your function definition. – user2045 Jun 7 '14 at 9:16
1

getActiveCarriers will return a list of carriers with their carrierCode and their associated model. Its not going to return the shipping methods.

To get these you need to call getAllowedMethods() on each of the carrier models. You will then get a list of carrier methods.

| improve this answer | |

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.