How can I enable shipping method only in admin section and hide from frontend in magento 2?

  • "How can I enable shipping method only in admin section and hide from backend in magento 2? " any typo here? Oct 31, 2016 at 4:56
  • Yes, thank you for pointing it out, I've just corrected. :)
    – nuwaus
    Oct 31, 2016 at 5:02

1 Answer 1


For this case, your override your shipping method Model class and collectRates() function return false .

Suppose, you want to disabled flat rate for frontend.

In this case,you need override the Magento\OfflineShipping\Model\Carrier\Flatrate.

di.xml (Namespace\Modulename\etc)

<?xml version="1.0"?>    
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\OfflineShipping\Model\Carrier\Flatrate" type="Namespace\Modulename\Model\Carrier\Flatrate" />
  • 1
    Thank you, this worked perfectly well, actually, I didn't need to override from di.xml because I already had my custom model. so I tested if the area code is adminhtml or storefront and switched accordingly.
    – nuwaus
    Oct 31, 2016 at 8:28
  • 1
    @Amit I know this is not related to question, but I'm facing issues at backend in rendering the shipping methods. While creating order from backend, it doesn't show shipping methods however at frontend it shows flat rate and table rates. Do you know the reason?
    – Deeps
    Feb 6, 2018 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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