Programmatically retrieve list of all shipping methods

后端 未结 3 597
眼角桃花
眼角桃花 2020-12-08 22:35

I\'m writing a quick-and-dirty module to restrict shipping methods based on products in the cart. For example, if the customer adds food, I only want overnight shipping met

3条回答
  •  执笔经年
    2020-12-08 22:59

    I've created a function for this out of the answers already provided. This creates an option group of all the shipping methods:

    function getShippingMethods($_methods, $fieldId, $fieldName, $fieldClass){
        $_shippingHtml = '';
        return $_shippingHtml;
    }
    

    The $_methods argument is an object from Magento:

    $_methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
    

    So, we can call the function and pass the $_methods object to it as follows:

    
    

    Hope that helps someone else.

提交回复
热议问题