0
I have Magneto 2.2.4 in which I have to hide DHL Shipping Method if Free Shipping is Available.

My Free Shipping is available if minimum order amount is greater than 200 .

Is there any Admin option to do this or I have to create a Module or install an Extension.


My Condition Setting

enter image description here

My Action Setting

enter image description here

3
  • You can do this using plugin of magento. – Dhiren Vasoya Mar 14 '20 at 9:25
  • Thanks For your Answer @Dhiren Vasoya I have change little bit in my Question have you any idea about it. – Prits Mar 14 '20 at 12:48
  • You can do this by coding, I post answer check that one. – Dhiren Vasoya Mar 16 '20 at 14:10
0

There is no admin option to do that, you would need to create a module and hook into native DHL carrier one. But what you can try and do is to set cart price rule that does not require a coupon (so it will be applied automatically) and set it as follows:

In conditions tab

If ALL  of these conditions are TRUE :
Subtotal (Excl. Tax)  equals or greater than  200  

In actions tab make discount amount 0 and under Apply the rule only to cart items matching the following conditions (leave blank for all items:

 Free Shipping: For shipment with matching items

This should switch shipping price to 0 for all shipments. If you have many options in DHL carrier that may not be enough though.

2
  • Thanks for the response @Zefiryn I Have a question Like if Customer is from Canada and Purchased a product more than 200$ So I want to make shipping Free. I have created cart rule for that but i think it doesn't apply on my Cart Page. Have you any idea to do that. I have attached screenshot of cart Rule. – Prits Mar 14 '20 at 10:42
  • Have you went to checkout and provided shipping address? Since you've added a rule that shipping country must be set to CA you need to go to firs step of the checkout and provide it. – Zefiryn Mar 14 '20 at 21:41
0

You can do this things using custom code.

  1. create plugin into your custom extension.

app\code\Vendor\Extension\etc\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Quote\Model\ShippingMethodManagement">
        <plugin name="shipping_method_management" type="Vendor\Extension\Plugin\Model\ShippingMethodManagement" disabled="false"/>
    </type>
</config>
  1. Now you need to put your logic into the that plugin file.

app\code\Vendor\Extension\Plugin\Model\ShippingMethodManagement.php

    <?php
    namespace Vendor\Extension\Plugin\Model;

    class ShippingMethodManagement 
    {


     public function afterEstimateByExtendedAddress($shippingMethodManagement, $output)
     {
         return $this->filterOutput($output);
     }

     private function filterOutput($output)
     {

         $isfree = 0;
         foreach ($output as $shippingMethod) 
         {
              if ($shippingMethod->getCarrierCode() == 'freeshipping' && $shippingMethod->getMethodCode() == 'freeshipping') 
              {
                  $isfree = 1;
              }
         }
         if ($isfree) 
         {
            // Freeshipping enable and available, so you can hide another method which you want and return that things.
         }
         return $output;
     }
  }

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.