I have created custom shipping method "Pick up at the store" and payment method "Pay in store" and I would like to hide all other payment methods, when I choose "Pick up at the store" shipping method.
I know, that payment method class has function "isAvailable", but it isn't a good idea to create special conditions for all available methods.
Please advice how I can hide all other payment method except "Pay in store", when "Pick up at the store" shipping method is choose. Thanks.
Best Answer
I tried DRAJAs code, but this does not work for me. The Shipping Method title is always NULL. I found another solution using the deprecated Cart Model. I also tried the new Quote model that should replace the Cart Model, but again this returned NULL... so I know it’s not according to Magento Standards, but it does do the trick for now.
The below example is used to hide the Klara payment method when a pick-up location is selected.
app/code/Company/Module/etc/events.xml
Company/Module/Observer/PaymentMethodAvailable.php