I have created a custom shipping module and have defined collectRates()
and other functions in the module.
I also have onepage checkout enabled. In that page this new shipping module is not getting called. The shipping amount is coming blank.
What do I have to do to get my checkout page and my cart page to automatically call this module to show the right shipping price?
I am using Magento 1.9.2
My carrier class is:
<?php
// app/code/local/Envato/Customshippingmethod/Model
class Shopez_Customshippingmethod_Model_Demo
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
{
protected $_code = 'shopez_customshippingmethod';
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$result = Mage::getModel('shipping/rate_result');
$result->append($this->_getDefaultRate());
return $result;
}
public function getAllowedMethods()
{
return array(
'shopez_standard' => 'Delivery Based on Cart Subtotal',
);
}
protected function _getDefaultRate()
{
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod($this->_code);
$rate->setMethodTitle('Delivery Based on Cart Subtotal');
$rate->setPrice($this->getConfigData('price'));
$rate->setCost(0);
return $rate;
}
protected function _getStandardRate()
{
/** @var Mage_Shipping_Model_Rate_Result_Method $rate */
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Delivery Based on Cart Subtotal');
$rate->setPrice(1.23);
$rate->setCost(0);
return $rate;
}
}