Hi all!
I am new to Shopify (usually work with WordPress) - I am helping friends with the design of their new Shopify store and I’m stuck on this particular request: In their collection called “subscription” they have subscription (mystery) boxes with a variety of items they sell. When ordering, they want their customers to let them know if they have any allergies and if there are specific products they for sure won’t like to receive in these boxes. Ideally it would be a mandatory field to fill out.
Now, after many hours and square eyes
, I have added/adapted a bit of code I found in the .dev section. I added it in (copy of Dawn theme) Themes → Sections → main-product.liquid under the “product-form__input product-form__quantity” line (as per something else I found on the forum). I added this:
{% form 'product', product %}
{% endform %}
This does show up in the product description (yay!), but how would I get it to show in ONLY the products in the collection “subscription”, not all the products? And does this actually work just like this? If I put one of those products in the cart, I don’t see anything of what I wrote in these boxes.
Or is there a better/easier way to get the customer to fill out this info and get it to the sellers upon ordering?
Hello @marlies_wobben
To only show only on Products of subscription collection you can follow below code.
{% form 'product', product %}
{% assign pro-found = false %}
{% for col in product.collections %}
{% if col.handle contains 'subscription' %}
{% assign pro-found = true %}
{% break%}
{% endfor %}
{% if pro-found %}
{% endif %}
{% endform %}
The word in single quote is collection handle >> What is Collection Handle ?
But you need to check that product properties are added in the cart or not. also you have to add code to show them on cart >> Cart code
Thank you so much! I checked your code and I followed the link to the cart code, where I ended up in another post about product customization where one of the options was to use an app for that. Now I would definitely be more comfortable using an app, but I had been searching for the wrong things. Looks like an app for product customization can give me those options for a text area for customers to give the extra info. I will go that route first and keep your code in mind too.
Hey Savior, I have followed your code exactly as shown; however, I keep running into an issue where the file cannot be saved because of syntax errors. Im not sure what I did wrong, but the syntax states that {% endform %} is not a valid delimiter.
I have added a screen shot of the entire page, please let me know if you can help !