Created
August 11, 2018 00:20
-
-
Save imbolc/33b97e6614449016c5f7a9791d4fa102 to your computer and use it in GitHub Desktop.
Shopify script to filter country-specific payment methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def allow_in(gateway, eligible_country_codes) | |
if Input.cart.shipping_address and eligible_country_codes.include?(Input.cart.shipping_address.country_code) | |
Output.payment_gateways = Input.payment_gateways | |
else | |
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway| | |
payment_gateway.name == gateway | |
end | |
end | |
end | |
allow_in('American Express', ['US', 'CA']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment