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





Lee

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



[CODE

{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





Lee

Does it work in 2.2.1?

Hello,

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

Hello!

If you are using CS-Cart Multi-Vendor, you can use the default Payments by country add-on for this. The add-on first appeared in version 4.11.4, so you may need to upgrade your installation to at least that version if you are using the older one.

To add to what my colleagues said above, we may make “Payments by country” available in one of the future versions of CS-Cart Store Builder Ultimate as well.

1 Like

what version are you on V4 ? if so this works well