Skip to content

Magento: Get List Active Shipping Methods & Payment Methods

this is functions to get / print list active shipping & payment methods, here we go!!

mantaps gann!!

public function getActivePaymentMethods()
{
$payments = Mage::getSingleton(‘payment/config’)->getActiveMethods();
$methods = array(array(‘value’=>”, ‘label’=>Mage::helper(‘adminhtml’)->__(‘–Please Select–‘)));
foreach ($payments as $paymentCode=>$paymentModel) {
$paymentTitle = Mage::getStoreConfig(‘payment/’.$paymentCode.’/title’);
$methods[$paymentCode] = array(
‘label’   => $paymentTitle,
‘value’ => $paymentCode,
);
}
return $methods;
}

public function getActiveShippingMethods()
{

$activeCarriers = Mage::getSingleton(‘shipping/config’)->getActiveCarriers();

//print_r($activeCarriers);
$allCarriers = array();

foreach($activeCarriers as $carrierCode => $carrierModel)
{
$options = array();

//print_r($carrierModel->getAllowedMethods());

if( $carrierMethods = $carrierModel->getAllowedMethods() )
{
$carrierTitle = Mage::getStoreConfig(‘carriers/’.$carrierCode.’/title’);
foreach ($carrierMethods as $methodCode => $method)
{
$code= $carrierCode.’_’.$methodCode;
$options[]=array(‘value’=>$code,’label’=>$carrierTitle.’ ‘.$method);
$allCarriers[] = array(‘value’=>$code,’label’=>$carrierTitle.’ ‘.$method);
}

}
$methods[]=array(‘value’=>$options,’label’=>$carrierTitle);
}

return $allCarriers;
}

Share

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *