1

Following this tutorial https://code.tutsplus.com/tutorials/create-a-custom-shipping-method-in-magento--cms-23747 i have created a new shipping method

enter image description here

and the price, following the tutorial, has been set up in the file config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Envato_Customshippingmethod>
      <version>1.0</version>
    </Envato_Customshippingmethod>
  </modules>
  <global>
    <models>
      <envato_customshippingmethod>
        <class>Envato_Customshippingmethod_Model</class>
      </envato_customshippingmethod>
    </models>
    <helpers>
      <envato_customshippingmethod>
        <class>Envato_Customshippingmethod_Helper</class>
      </envato_customshippingmethod>
    </helpers>
  </global>
  <default>
    <carriers>
      <envato_customshippingmethod>
        <active>1</active>
        <sallowspecific>1</sallowspecific>
        <model>envato_customshippingmethod/demo</model>
        <name>Demo Shipping Method One</name>
        <price>8.53</price>
        <title>Demo Shipping Method</title>
      </envato_customshippingmethod>
    </carriers>
  </default>
</config>

The new shipping method appear to work fine, without any kind of problem, but if i try to set up a checkout rule to put the shipping method free for order over 30,00€ the rules is not applied

enter image description here

enter image description here

Maybe is a problem of the new shipping method?....or maybe i wrong something in the rule?

0

I made it to work in this way finally, Go to your Model file mine is Carrier.php and inside public function collectRates(Mage_Shipping_Model_Rate_Request $request) you have to add the code below:

    if ($request->getFreeShipping()) {
        /**
         *  If the request has the free shipping flag,
         *  append a free shipping rate to the result.
         */
        $freeShippingRate = $this->_getFreeShippingRate();
        $result->append($freeShippingRate);
    }

After that, you have to add allow the free method inside the public function getAllowedMethods() as below:

    return array(
        'standard'    =>  'Standard Method',
        'free_shipping' => 'Free Shipping', //Add this one into your array
    );

After that you have to add a new function for the free shipping of course as below:

protected function _getFreeShippingRate()
{
    /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
    $rate = Mage::getModel('shipping/rate_result_method');

    $rate->setCarrier($this->_code);
    $rate->setCarrierTitle('Envato'); //Change with your carrier name
    $rate->setMethod('free_shipping');
    $rate->setMethodTitle('Free Shipping');
    $rate->setPrice(0);
    $rate->setCost(0);

    return $rate;
}

When you finish this edits you will find that cart price rules with free shipping option will be applied normally on your custom shipping method.

Please accept it as Answer, I was trying to get it work for 2 months like you, and just fixed it yesterday.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.