Payment restriction by Country

Hi All

Sorry I posted this on an old thread but didn’t notice it was version 1

I need to restrict Paypal to UK only, I’ve tried adding this to the checkbox code in payment_methods.tpl but it still shows paypal

{if $pm.payment_id == 12 && $cart.user_data['b_country'] == 'gbp' && $cart.user_data['s_country'] == 'gbp'}

Even if the syntax was wrong I thought it would hide the payment option

Can anyone help? I don’t want to go down the localizations route as it will mean half rebuilding the site!

Thank you


Hi all

I got this to work so I’ll post here in case anyone else needs it

In my_changes/hooks I created a folder called checkout and a new file called payment_methods.override.tpl

I added this code after line 1 (foreach line) (copied the full hook of course) and then added {/if} before the foreach close


{if $pm.payment_id == 12 && $cart.user_data.s_country != ‘GB’ && $cart.user_data.b_country != ‘GB’}

Paypal not allowed for this location

{else} ```

Basically if payment method is paypal (ID 12 on my system) and the billing and shipping address are not both GB then it just display the paypal not allowed text

Hope this helps others


Does it work in 2.2.1?


I am looking almost same solution. I need to disable payment methods for all countries except few. Can someone point me in the direction of which file should I make the changes?

Try to check hooks in the fn_prepare_checkout_payment_methods function (app/functions/fn.cart.php)

1 Like