How to, for example, enable cash on delivery payment only when customer selected flat rate shipping method?
I cannot find a way doing this in shipment/payment configuration or in cart rules.
magento2payment-methodsshipping-methods
How to, for example, enable cash on delivery payment only when customer selected flat rate shipping method?
I cannot find a way doing this in shipment/payment configuration or in cart rules.
Best Answer
I use an plugin in a custom module to set the
isAvailable()
function forMagento\OfflinePayments\Model\Cashondelivery
to false when shipping methodflatrate_flatrate
is selected.file:
<magento-root>/app/code/MyCompany/MyModule/Plugin/CashondeliveryPlug.php
file:
<magento-root>/app/code/MyCompany/MyModule/etc/di.xml
Hope this helps you! Feel free to ask any questions.