Deepak Mankotia
Deepak Mankotia

Reputation: 4564

How do i get shipping method of current Store : Magento

I am creating functionality to get Shipping methods enabled for selected store.

Currently I am using below code to get Shipping details :

$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shipMethods = array();

foreach ($methods as $shippigCode=>$shippingModel) 
{

    $shippingTitle = Mage::getStoreConfig('carriers/'.$shippigCode.'/title');
    $shippingPrice = Mage::getStoreConfig('carriers/'.$shippigCode.'/price');
    $shippingLabel = Mage::getStoreConfig('carriers/'.$shippigCode.'/label');
    $shipMethods[]=array('Shipping Type' => $shippigCode, 'title'=> $shippingTitle, 'price'=> $shippingPrice);


}
print_r($shipMethods);

I only get config details of the default store.

My question is : How do i get shipping methods of selected store?

Upvotes: 3

Views: 2012

Answers (1)

Vikrant Vir Bhalla
Vikrant Vir Bhalla

Reputation: 299

By default the value is null in getActiveCarriers

getActiveCarriers($store = null)

So you can pass the store as a parameter. You can get the current store with

Mage::app()->getStore()->getStoreId()

So the function you will use is

Mage::getSingleton('shipping/config')->getActiveCarriers(Mage::app()->getStore()->getStoreId())

Upvotes: 6

Related Questions