How to get the shipping method of the current store: Magento
I am creating functionality to enable shipping methods for a selected store.
I am currently using the code below to get shipping information:
$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 the default storage configuration data.
My question is: How do I get the shipping methods of the selected store?
+3
source to share
1 answer
The default 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()
Thus, the function you will be using is
Mage::getSingleton('shipping/config')->getActiveCarriers(Mage::app()->getStore()->getStoreId())
+6
source to share