2

Create a plugin using for class Magento\OfflineShipping\Model\Carrier\Freeshipping. Use after method (afterCollectRates) for CollectRates function.

But this does not work

here list of files:

  • app/code/AmitBera/CoreRewrite/etc/module.xml

code:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNameSpaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="AmitBera_CoreRewrite" setup_version="2.0.0">
        <sequence>
            <module name="Magento_Checkout"/>
            <module name="Magento_Sales"/>
            <module name="Magento_Quote"/>
            <module name="Magento_Vault"/>
            <module name="Magento_OfflineShipping"/>           
        </sequence>     
    </module>
</config>
  • app/code/AmitBera/CoreRewrite/etc/frontend/di.xml

code:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Magento\OfflineShipping\Model\Carrier\Freeshipping">
        <plugin name="disabledfreeShippingforfrontend" type="AmitBera\CoreRewrite\Model\Plugin\DisabledFreeShippingForFront" sortOrder="1" />
    </type>
</config>   
  • app/code/AmitBera/CoreRewrite/Model/Plugin/DisabledFreeShippingForFront.php

code:

<?php
namespace AmitBera\CoreRewrite\Model\Plugin;
/**
* Disabled Freeshipping for frontend
*/
class DisabledFreeShippingForFront
{
    public function afterCollectRates(\Magento\OfflineShipping\Model\Carrier\Freeshipping $Freeshipping ,$result)
    {
        $this->_logger->debug(__METHOD__);
         return false;
    }

}

Also have the registration.php

Also i check the Limitations of plugin from http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

  • Does not find any final class at Magento\OfflineShipping\Model\Carrier\Freeshipping
  • Does not find any final Final classes

Now,Please let me know where i goes to wrong except this two limited which limitation is create issue in my plugin

Your Answer

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

Browse other questions tagged or ask your own question.