Return to Snippet

Revision: 52952
at November 7, 2011 19:42 by etechblog


Initial Code
class Excellence_Pickup_Model_Carrier_Pickup extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface {
 
    protected $_code = 'pickup';
 
    public function getFormBlock(){
        return 'pickup/pickup';
    }
 
    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
            return false;
        }
 
        $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
        $result = Mage::getModel('shipping/rate_result');
        $method = Mage::getModel('shipping/rate_result_method');
        $method->setCarrier($this->_code);
        $method->setMethod($this->_code);
        $method->setCarrierTitle($this->getConfigData('title'));
        $method->setMethodTitle($this->getConfigData('name'));
        $method->setPrice($this->getConfigData('price'));
        $method->setCost($this->getConfigData('price'));
        $result->append($method);
        return $result;
    }
    public function getAllowedMethods()
    {
        return array('excellence'=>$this->getConfigData('name'));
    }
}

Initial URL
http://www.excellencemagentoblog.com/magento-advanced-shipping-method-development

Initial Description
In this tutorial, we are going to see how to create a shipping method with form fields.

Initial Title
Magento Shipping Method Development

Initial Tags
magento

Initial Language
PHP