Last active
December 12, 2017 14:48
-
-
Save dommmel/5d536f4e3a42b1e3d5c975c1510a5f2a to your computer and use it in GitHub Desktop.
Shopify Script to enable payment gateway only for customer with a certain tag
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
PAYMENT_GATEWAY_NAME = 'Invoice' | |
CUSTOMER_TAG = 'VIP' | |
customer = Input.cart.customer | |
remove_gateway = (customer.nil? or !customer.tags.include?(CUSTOMER_TAG)) | |
if remove_gateway | |
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway| | |
payment_gateway.name == PAYMENT_GATEWAY_NAME | |
end | |
else | |
Output.payment_gateways = Input.payment_gateways | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment