简体   繁体   中英

Shopify Custom Text box according to product collection

Im trying to do a conditional where if a product is in collection "personal" it will show a text box. I have this in the product.liquid page but it does't seem to be working.

   {% if collection.title == 'personal' %}
            <div>                             
              <p><input type="text" id="letter" placeholder="Enter up to 6 Letters" name="properties[letter]" /></p>
            </div>
   {% endif %}

Try this:

{% for collection in product.collections %}
  {% if collection.handle == 'personal' %}
    <div>                             
      <p><input type="text" id="letter" placeholder="Enter up to 6 Letters" name="properties[letter]" /></p>
    </div>
  {% endif %}
{% endfor %}

See the Shopify docs for product.collections .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM