Enable Cash on delivery option for specific produc

2019-07-29 12:03发布

问题:

I have developed the magento website called https://tumree.com and I needto enable COD for test product.

URL: https://tumree.com/test-product I need to enable cash on delivery for above product only. There is a option for disable COD for specific product. But I need to enable for one.

I have tried writing rule in shopping cart rule. But couldn't fix the issue. Pls help me to find the solution...

回答1:

you can go to System > configuration > Payment method you can enter Maximum order total to "2" and than you can set the test product price to "1" , than it will display COD only for test product.



回答2:

You can use the event payment_method_is_active

You will get the name of the payment method. Use an if condition to check if its COD and then load the items in your quote. Check if its product id matches with your test product and if yes then enable the payment method or else disable it.

The code to disable the payment method is:

$result = $observer->getResult();
$result->isAvailable = false;

where setting it to false disables it.