Magento 2: How to hide shipping method on front end for custom logicShipping method only avialable for manual order creation 1.9Custom Shipping Method only for logged usersMagento2 : custom rate for shipping methodExtension attribute for shipping method in Magento 2Magento 2 : Custom online shipping method with shipping APIremove free shipping method from custom shipping module magento2magento 2: Hide shipping method in frontendupdate shipping address for shipping method changeMagento2 - Add Custom fields block after shipping method

If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?

tikz: 5 squares on a row, roman numbered 1 -> 5

Good examples of "two is easy, three is hard" in computational sciences

Germany rejected my entry to Schengen countries

RAID 5/6 rebuild time calculation

Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?

What Species of Trees are These?

Keeping the dodos out of the field

Why is there no current between two capacitors connected in series?

Why was Harry at the Weasleys' at the beginning of Goblet of Fire but at the Dursleys' after?

Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?

Managing heat dissipation in a magic wand

Does George B Sperry logo on fold case for photos indicate photographer or case manufacturer?

Vehemently against code formatting

What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?

Best practice for printing and evaluating formulas with the minimal coding

How to safely discharge oneself

Existence of a model of ZFC in which the natural numbers are really the natural numbers

Rotate and duplicate row values in Google Sheets

Expand a hexagon

How should I mix small caps with digits or symbols?

pwaS eht tirsf dna tasl setterl fo hace dorw

Does the Aboleth have expertise in History and Perception?

Connecting circles clockwise in TikZ



Magento 2: How to hide shipping method on front end for custom logic


Shipping method only avialable for manual order creation 1.9Custom Shipping Method only for logged usersMagento2 : custom rate for shipping methodExtension attribute for shipping method in Magento 2Magento 2 : Custom online shipping method with shipping APIremove free shipping method from custom shipping module magento2magento 2: Hide shipping method in frontendupdate shipping address for shipping method changeMagento2 - Add Custom fields block after shipping method






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.










share|improve this question




























    1















    Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.










    share|improve this question
























      1












      1








      1








      Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.










      share|improve this question














      Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.







      magento2 shipping-methods custom-shipping-method






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 5 '17 at 16:10









      AbhishekAbhishek

      443823




      443823




















          2 Answers
          2






          active

          oldest

          votes


















          1














          It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate



          public function collectRates(RateRequest $request)

          if (!$this->getConfigFlag('active'))
          return false;

          if($customeProductConditionFalse)

          return false;

          ........



          In this method you can check your condition for product custom attribute match or not and



          return false;


          to disable shipping method






          share|improve this answer























          • i can add product attribute condition but what is the code for disable shipping method.

            – Dhaval Patel
            Mar 27 '18 at 12:30











          • you need to send return false to disable it

            – Vaibhav Ahalpara
            Mar 27 '18 at 13:30











          • Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

            – Dhaduk Mitesh
            Jul 7 '18 at 9:17












          • @DhadukMitesh Did you find the solution for this?

            – Pratik Kamani
            May 14 at 11:17











          • @PratikKamani Please check my answer.

            – Dhaduk Mitesh
            May 14 at 12:48


















          0














          Create 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="MagentoQuoteApiShipmentEstimationInterface">
          <plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
          </type>
          </config>


          Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php.



          <?php

          namespace VendorModulePluginQuoteApi;

          use MagentoQuoteApiShipmentEstimationInterface;

          class ShipmentEstimationPlugin

          public function __construct(
          MagentoCustomerModelSession $customerSession
          )
          $this->customerSession = $customerSession;


          public function aroundEstimateByExtendedAddress(
          ShipmentEstimationInterface $subject,
          Closure $proceed,
          $cartId,
          MagentoQuoteApiDataAddressInterface $address
          )
          $shippingMethods = $proceed($cartId, $address);
          if ($this->customerSession->isLoggedIn())
          foreach ($shippingMethods as $key => $shippingMethod)
          //Replace 'freeshipping' with your shipping method which you want to hide
          if ($shippingMethod->getMethodCode() == 'freeshipping')
          unset($shippingMethods[$key]);



          return $shippingMethods;





          It will work for you.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167828%2fmagento-2-how-to-hide-shipping-method-on-front-end-for-custom-logic%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate



            public function collectRates(RateRequest $request)

            if (!$this->getConfigFlag('active'))
            return false;

            if($customeProductConditionFalse)

            return false;

            ........



            In this method you can check your condition for product custom attribute match or not and



            return false;


            to disable shipping method






            share|improve this answer























            • i can add product attribute condition but what is the code for disable shipping method.

              – Dhaval Patel
              Mar 27 '18 at 12:30











            • you need to send return false to disable it

              – Vaibhav Ahalpara
              Mar 27 '18 at 13:30











            • Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

              – Dhaduk Mitesh
              Jul 7 '18 at 9:17












            • @DhadukMitesh Did you find the solution for this?

              – Pratik Kamani
              May 14 at 11:17











            • @PratikKamani Please check my answer.

              – Dhaduk Mitesh
              May 14 at 12:48















            1














            It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate



            public function collectRates(RateRequest $request)

            if (!$this->getConfigFlag('active'))
            return false;

            if($customeProductConditionFalse)

            return false;

            ........



            In this method you can check your condition for product custom attribute match or not and



            return false;


            to disable shipping method






            share|improve this answer























            • i can add product attribute condition but what is the code for disable shipping method.

              – Dhaval Patel
              Mar 27 '18 at 12:30











            • you need to send return false to disable it

              – Vaibhav Ahalpara
              Mar 27 '18 at 13:30











            • Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

              – Dhaduk Mitesh
              Jul 7 '18 at 9:17












            • @DhadukMitesh Did you find the solution for this?

              – Pratik Kamani
              May 14 at 11:17











            • @PratikKamani Please check my answer.

              – Dhaduk Mitesh
              May 14 at 12:48













            1












            1








            1







            It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate



            public function collectRates(RateRequest $request)

            if (!$this->getConfigFlag('active'))
            return false;

            if($customeProductConditionFalse)

            return false;

            ........



            In this method you can check your condition for product custom attribute match or not and



            return false;


            to disable shipping method






            share|improve this answer













            It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate



            public function collectRates(RateRequest $request)

            if (!$this->getConfigFlag('active'))
            return false;

            if($customeProductConditionFalse)

            return false;

            ........



            In this method you can check your condition for product custom attribute match or not and



            return false;


            to disable shipping method







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 6 '17 at 7:27









            Vaibhav AhalparaVaibhav Ahalpara

            3,70042762




            3,70042762












            • i can add product attribute condition but what is the code for disable shipping method.

              – Dhaval Patel
              Mar 27 '18 at 12:30











            • you need to send return false to disable it

              – Vaibhav Ahalpara
              Mar 27 '18 at 13:30











            • Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

              – Dhaduk Mitesh
              Jul 7 '18 at 9:17












            • @DhadukMitesh Did you find the solution for this?

              – Pratik Kamani
              May 14 at 11:17











            • @PratikKamani Please check my answer.

              – Dhaduk Mitesh
              May 14 at 12:48

















            • i can add product attribute condition but what is the code for disable shipping method.

              – Dhaval Patel
              Mar 27 '18 at 12:30











            • you need to send return false to disable it

              – Vaibhav Ahalpara
              Mar 27 '18 at 13:30











            • Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

              – Dhaduk Mitesh
              Jul 7 '18 at 9:17












            • @DhadukMitesh Did you find the solution for this?

              – Pratik Kamani
              May 14 at 11:17











            • @PratikKamani Please check my answer.

              – Dhaduk Mitesh
              May 14 at 12:48
















            i can add product attribute condition but what is the code for disable shipping method.

            – Dhaval Patel
            Mar 27 '18 at 12:30





            i can add product attribute condition but what is the code for disable shipping method.

            – Dhaval Patel
            Mar 27 '18 at 12:30













            you need to send return false to disable it

            – Vaibhav Ahalpara
            Mar 27 '18 at 13:30





            you need to send return false to disable it

            – Vaibhav Ahalpara
            Mar 27 '18 at 13:30













            Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

            – Dhaduk Mitesh
            Jul 7 '18 at 9:17






            Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.

            – Dhaduk Mitesh
            Jul 7 '18 at 9:17














            @DhadukMitesh Did you find the solution for this?

            – Pratik Kamani
            May 14 at 11:17





            @DhadukMitesh Did you find the solution for this?

            – Pratik Kamani
            May 14 at 11:17













            @PratikKamani Please check my answer.

            – Dhaduk Mitesh
            May 14 at 12:48





            @PratikKamani Please check my answer.

            – Dhaduk Mitesh
            May 14 at 12:48













            0














            Create 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="MagentoQuoteApiShipmentEstimationInterface">
            <plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
            </type>
            </config>


            Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php.



            <?php

            namespace VendorModulePluginQuoteApi;

            use MagentoQuoteApiShipmentEstimationInterface;

            class ShipmentEstimationPlugin

            public function __construct(
            MagentoCustomerModelSession $customerSession
            )
            $this->customerSession = $customerSession;


            public function aroundEstimateByExtendedAddress(
            ShipmentEstimationInterface $subject,
            Closure $proceed,
            $cartId,
            MagentoQuoteApiDataAddressInterface $address
            )
            $shippingMethods = $proceed($cartId, $address);
            if ($this->customerSession->isLoggedIn())
            foreach ($shippingMethods as $key => $shippingMethod)
            //Replace 'freeshipping' with your shipping method which you want to hide
            if ($shippingMethod->getMethodCode() == 'freeshipping')
            unset($shippingMethods[$key]);



            return $shippingMethods;





            It will work for you.






            share|improve this answer





























              0














              Create 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="MagentoQuoteApiShipmentEstimationInterface">
              <plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
              </type>
              </config>


              Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php.



              <?php

              namespace VendorModulePluginQuoteApi;

              use MagentoQuoteApiShipmentEstimationInterface;

              class ShipmentEstimationPlugin

              public function __construct(
              MagentoCustomerModelSession $customerSession
              )
              $this->customerSession = $customerSession;


              public function aroundEstimateByExtendedAddress(
              ShipmentEstimationInterface $subject,
              Closure $proceed,
              $cartId,
              MagentoQuoteApiDataAddressInterface $address
              )
              $shippingMethods = $proceed($cartId, $address);
              if ($this->customerSession->isLoggedIn())
              foreach ($shippingMethods as $key => $shippingMethod)
              //Replace 'freeshipping' with your shipping method which you want to hide
              if ($shippingMethod->getMethodCode() == 'freeshipping')
              unset($shippingMethods[$key]);



              return $shippingMethods;





              It will work for you.






              share|improve this answer



























                0












                0








                0







                Create 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="MagentoQuoteApiShipmentEstimationInterface">
                <plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
                </type>
                </config>


                Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php.



                <?php

                namespace VendorModulePluginQuoteApi;

                use MagentoQuoteApiShipmentEstimationInterface;

                class ShipmentEstimationPlugin

                public function __construct(
                MagentoCustomerModelSession $customerSession
                )
                $this->customerSession = $customerSession;


                public function aroundEstimateByExtendedAddress(
                ShipmentEstimationInterface $subject,
                Closure $proceed,
                $cartId,
                MagentoQuoteApiDataAddressInterface $address
                )
                $shippingMethods = $proceed($cartId, $address);
                if ($this->customerSession->isLoggedIn())
                foreach ($shippingMethods as $key => $shippingMethod)
                //Replace 'freeshipping' with your shipping method which you want to hide
                if ($shippingMethod->getMethodCode() == 'freeshipping')
                unset($shippingMethods[$key]);



                return $shippingMethods;





                It will work for you.






                share|improve this answer















                Create 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="MagentoQuoteApiShipmentEstimationInterface">
                <plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
                </type>
                </config>


                Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php.



                <?php

                namespace VendorModulePluginQuoteApi;

                use MagentoQuoteApiShipmentEstimationInterface;

                class ShipmentEstimationPlugin

                public function __construct(
                MagentoCustomerModelSession $customerSession
                )
                $this->customerSession = $customerSession;


                public function aroundEstimateByExtendedAddress(
                ShipmentEstimationInterface $subject,
                Closure $proceed,
                $cartId,
                MagentoQuoteApiDataAddressInterface $address
                )
                $shippingMethods = $proceed($cartId, $address);
                if ($this->customerSession->isLoggedIn())
                foreach ($shippingMethods as $key => $shippingMethod)
                //Replace 'freeshipping' with your shipping method which you want to hide
                if ($shippingMethod->getMethodCode() == 'freeshipping')
                unset($shippingMethods[$key]);



                return $shippingMethods;





                It will work for you.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 14 at 13:02

























                answered May 14 at 12:47









                Dhaduk MiteshDhaduk Mitesh

                667218




                667218



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167828%2fmagento-2-how-to-hide-shipping-method-on-front-end-for-custom-logic%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form