Posted By

etechblog on 11/07/11


Tagged

method magento Shipping


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

WGenie


Magento Shipping Method Development


 / Published in: PHP
 

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

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

  1. class Excellence_Pickup_Model_Carrier_Pickup extends Mage_Shipping_Model_Carrier_Abstract
  2. implements Mage_Shipping_Model_Carrier_Interface {
  3.  
  4. protected $_code = 'pickup';
  5.  
  6. public function getFormBlock(){
  7. return 'pickup/pickup';
  8. }
  9.  
  10. public function collectRates(Mage_Shipping_Model_Rate_Request $request)
  11. {
  12. if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
  13. return false;
  14. }
  15.  
  16. $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
  17. $result = Mage::getModel('shipping/rate_result');
  18. $method = Mage::getModel('shipping/rate_result_method');
  19. $method->setCarrier($this->_code);
  20. $method->setMethod($this->_code);
  21. $method->setCarrierTitle($this->getConfigData('title'));
  22. $method->setMethodTitle($this->getConfigData('name'));
  23. $method->setPrice($this->getConfigData('price'));
  24. $method->setCost($this->getConfigData('price'));
  25. $result->append($method);
  26. return $result;
  27. }
  28. public function getAllowedMethods()
  29. {
  30. return array('excellence'=>$this->getConfigData('name'));
  31. }
  32. }

Report this snippet  

You need to login to post a comment.