Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Good morning!
We are getting set up to sell class materials through Shopify. I got this set up to show a dropdown to select the class this is for, as well as a text box for the student name, in case it's different from the name on the order. The issue I am running into at the moment is that if there are multiple materials on the order, only the information from the final item on the order is saved. We are needing the information from the input on each item.
Here's the code added to the cart template creating the requests and collecting information:
<tr>
<td>
{% for tag in item.product.tags %}
{%- if tag == "Clay Class Supplies" -%}
<div>
<p class="cart-attribute__field">
<label>Please select the class this is being purchased for:</label><br>
<select required class="required" id="Class-label-for-materials" name="attributes[Class label for materials]">
<option disabled selected value=""> -- please select an option -- </option>
<option value="Introduction to Ceramics">Introduction to Ceramics</option>
<option value="Wheel Throwing 1">Wheel Throwing 1</option>
<option value="Handbuilding: Vessels">Handbuilding: Vessels</option>
<option value="I like Big Bowls">I like Big Bowls</option>
<option value="Ceramic Surface Design with Underglaze">Ceramic Surface Design with Underglaze</option>
</select>
</p>
</div>
{% endif %}
{% endfor %}
</td><td>
{% for tag in item.product.tags %}
{%- if tag == "Clay Class Supplies" -%}
<p class="cart-attribute__field">
<label for="student-name">Student name</label>
<input required class="required" id="student-name" type="text" name="attributes[Student name]" value="{{ cart.attributes["Student name"] }}">
</p>
{% endif %}
{% endfor %}
</td>
</tr>
(I'm sure there's some cleanup to be done. I tried to get rid of what look like duplicate triggers to check for the same tag, but the editor got mad at me about something else when I did that so I just put it back.)
Thank you for any insight!
I've located another problem related to this that I'm not sure how to fix. On the cart page, if an item is removed, dropdown and text boxes both disappear and Check Out button becomes usable without filling out otherwise required fields.
I have novalidate removed for that table, but it seems to see everything as validated when the fields aren't generated. If I load the cart page again, the fields will reappear.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025