4

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

1)DHL 2)FEDEX 3)INDIA POST

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 '17 at 11:21
  • 1
    Non of the magento default rule options used to hide shipping method. You need to do custom code for this. – Dhiren Vasoya Nov 7 '17 at 11:30
  • @jscar Is any other option available instead of webshopapps product matrix? – zus Nov 7 '17 at 11:32
  • @DhirenVasoya could you pls share any idea how to hit this? – zus Nov 7 '17 at 11:33
  • @zus there may be other commercial extensions but I don't know of them. – jscar Nov 7 '17 at 11:42
0

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

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

<global>
        <blocks>
            <checkout>
                <rewrite>
                    <onepage_shipping_method_available>Vendor_Extension_Block_Method</onepage_shipping_method_available>
                </rewrite>
            </checkout>
        </blocks>
<global>

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

<?php
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) {
            unset($rates['your_shipping_method_code']);
        }

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

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.