Show/Hide payment gateways according to shipping method

We often face this issue.¬† Sometimes we want to activate specific payment gateways¬† depending on selected shipping method. Here is the code —

 

Line 2 : We are getting the selected shipping method.
Line 4: We are checking whether it is local delivery or not (you can put your own shipping method or some other logic) .
Line 6: Now disabling payment gateways.
So in this way you can hide all the payment gateways which you don’t want to make available for the local delivery (or whatever).

Feel free to ask if you have any doubt.

2 Replies to “Show/Hide payment gateways according to shipping method”

  1. isolation froid says:

Leave a Reply

Your email address will not be published. Required fields are marked *