Last active
May 18, 2022 07:03
-
-
Save magician11/2c63ce78f4dffb5fc941c8d843717242 to your computer and use it in GitHub Desktop.
How to remove the PayPal payment gateway in Shopify if a product is tagged with 'no-paypal'.
This file contains 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
has_no_paypal_tag = Input.cart.line_items.any? { |line_item| line_item.variant.product.tags.include?('no-paypal') } | |
if has_no_paypal_tag | |
Output.payment_gateways = Input.payment_gateways.delete_if { |payment_gateway| payment_gateway.name.include?("PayPal") } | |
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