Skip to content

Instantly share code, notes, and snippets.

@magician11
Last active May 18, 2022 07:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magician11/2c63ce78f4dffb5fc941c8d843717242 to your computer and use it in GitHub Desktop.
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'.
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