Display/Hide Express checkout buttons based on products in cart

New Member
1 0 0


I want to display/hide express check out buttons based on the product type in the cart. Is there any solution for this? 

In my case i want to hide Amazon Pay/PayPal buttons for certain products if cart contains those products. 

Shopify Partner
1975 296 784

You can make a case statement to check product handles, product type, product tags, whatever. Make a condition that is initially true, then if any of the conditions are met, set it to false. Lets say you tag your products "no-alternate-checkout", you could check the product tags and see if the tag exists -- if it does, set the condition to false and only show the payment buttons if it's true:

{% assign show_alternate_checkout = true %}
{% for item in cart.line_items %}
  {% assign product = item.product %}
  {% if product.tags contains 'no-alternate-checkout' %}
    {% assign show_alternate_checkout = false %}
  {% endif %}
{% endfor %}

{% if show_alternate_checkout %}
{{ content_for_additional_checkout_buttons }}
{% endif %}


If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D