Return Enabled Shipping Methods in Magento (Workbench Script)

Submitted by deeperdata - 1 year ago

While debugging a module I had written that makes use of available shipping methods, I realized I needed the available methods and their corresponding code/value. Here is quick script that will do just that.

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$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)");
}
echo "<pre>";
print_r($options);
echo "</pre>";
affiliate_link
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean