If anyone of the selected Categories of products presents in the cart the shipping method is admin selected one. now my shipping methods like user selections, like


If the anyone of the selected Categories of products presents in the cart, no matter other categories of products also included in the cart. if my selected Categories of products presents in the cart the shipping method is INDIA POST

How can i solve this issue? can i get an idea about how to write Manual PHP Condition?

  • 1
    If I have understood you correctly I don't think you can do this from a shipping cart rule. You need a third party extension (something like webshopapps product matrix) and then use an attribute to control which shipping methods are used for different products
    – jscar
    Nov 7, 2017 at 11:21
  • 1
    Non of the magento default rule options used to hide shipping method. You need to do custom code for this. Nov 7, 2017 at 11:30
  • @jscar Is any other option available instead of webshopapps product matrix?
    – zus
    Nov 7, 2017 at 11:32
  • @DhirenVasoya could you pls share any idea how to hit this?
    – zus
    Nov 7, 2017 at 11:33
  • @zus there may be other commercial extensions but I don't know of them.
    – jscar
    Nov 7, 2017 at 11:42

1 Answer 1


You need to implement below code in any one custom extension.

Add this code in your config.xml file of your extension.


Create file Vendor/Extension/Block/Method.php which remove your shipping method based on condition:

class Vendor_Extension_Block_Method extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
    public function getShippingRates()
        $yourtempvar = true;
        // BASED ON CONDITION SET VALUE true false in $yourtempvar variable

        $rates = parent::getShippingRates();
        if (array_key_exists('your_shipping_method_code', $rates) && $yourtempvar !== false) {

        return $rates;
  • 1
    bro, Thank You. could you pls explain briefly
    – zus
    Nov 7, 2017 at 11:52
  • Already explain in brief bro. you need to implement the code. Nov 7, 2017 at 11:53
  • 1
    I am adding XML code to Webshopapps_Matrixrate Module : config.xml : codepaste.net/2pn6bn
    – zus
    Nov 8, 2017 at 11:17
  • 1
    and app\code\local\Gta\Extension\Block\Method.php : codepaste.net/f6qzhq
    – zus
    Nov 8, 2017 at 11:19
  • 1
    May i know what is the "your_shipping_method_code"
    – zus
    Nov 8, 2017 at 11:20

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.