Possible to have certain cart attributes show up only for certain products

Hi!

Right now for my store, I have added custom code using https://community.shopify.com/c/shopify-design/cart-use-cart-attributes-to-collect-more-information/td-p/613718 to collect additional information from my customers.

I am wondering if it is possible to have the custom code inputs be shown for only certain products but not all. A solution I think would be adding certain tags on all my products and using the tags to reference whether the code would display certain fields or not.

Is this possible or is there a better way to execute this? Thank you very much!

Hello @tedchangeth ,

They are different ways to make it conditional:

  1. Using metafields on/off option
  2. With tags
  3. Directly make it conditional but this one is useful when you have to apply it on 2-3 products.
    e.g.

{% if product.handle == ‘first-product’ or product.handle == ‘second-product’ %}

Display options
{% endif %}

Thanks

1 Like

Use alternate templates that don’t have those custom inputs

https://shopify.dev/themes/architecture/templates#alternate-templates

1 Like

Thank you so much for your reply! If I want to use tags since I think it will be the easiest, would it look something like this?

{% if product.tag == ‘tag name’ %}

Display options
{% endif %}

{% if product.tags contains 'your_tag' %}
Display options
{% endif %}
1 Like

Thank you! Would I add that into the form html?