Liquid, JavaScript, themes, sales channels
Hi 🙂
I try to show this form for each product == 0 in the cart.
{% if item.original_line_price == 0 %}
<div id="1kid" style="width:46%; float:left; margin: 2%; text-align: left;">
<p class="cart-attribute__field">
<label for="creative-kids-voucher">Creative Kids Voucher Number (16 digits starting with 9999) test {{ item.product_id }}</label>
<label>Start by 9999 plus 12 digits</label>
<input required class="required" id="creative-kids-voucher" type="text" placeholder="9999123456789123" pattern="[9]{4}[0-9]{12}" title="Start by 9999 plus 12 digits" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label for="first-childs-full">Child's Full Name (as shown on voucher)</label>
<label>Start by a Capslock ex: Jhon Doe</label>
<input required class="required" id="first-childs-full" type="text" placeholder="Jhon Doe" title="Start by a Capslock ex: Jhon Doe" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label for="first-childs-date-of-birth">Child's Date of Birth</label>
<label>Format of the date of Birthday ex:mm/jj/aaaa 03/13/1999</label>
<input required class="required" id="first-childs-date-of-birth" type="text" pattern="\d{2}/\d{2}/\d{4}" placeholder="10/25/2012" title="Format of the date of Birthday ex:mm/jj/aaaa 03/13/1999" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label>Child Gender</label><br>
<select required class="required" id="{{ cart.attributes.product.product_id }}" name="Gender{{ cart.attributes.product.product_id }}">
<option value="Girl"{% if cart.attributes.product.product_id == "Girl" %} selected{% endif %}>Girl</option>
<option value="Boy"{% if cart.attributes.product.product_id == "Boy" %} selected{% endif %}>Boy</option>
</select>
</p>
</div>
{% endif %}
It works but if i have 2 time the same product it show me only 1 form instead of 2.
Do you have an idea ?
Thanks 🙂
Regards,
Try like this.
{% if item.original_line_price == 0 %}
{% for quantity in item.quantity %}
<div id="1kid" style="width:46%; float:left; margin: 2%; text-align: left;">
<p class="cart-attribute__field">
<label for="creative-kids-voucher">Creative Kids Voucher Number (16 digits starting with 9999) test {{ item.product_id }}</label>
<label>Start by 9999 plus 12 digits</label>
<input required class="required" id="creative-kids-voucher" type="text" placeholder="9999123456789123" pattern="[9]{4}[0-9]{12}" title="Start by 9999 plus 12 digits" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label for="first-childs-full">Child's Full Name (as shown on voucher)</label>
<label>Start by a Capslock ex: Jhon Doe</label>
<input required class="required" id="first-childs-full" type="text" placeholder="Jhon Doe" title="Start by a Capslock ex: Jhon Doe" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label for="first-childs-date-of-birth">Child's Date of Birth</label>
<label>Format of the date of Birthday ex:mm/jj/aaaa 03/13/1999</label>
<input required class="required" id="first-childs-date-of-birth" type="text" pattern="\d{2}/\d{2}/\d{4}" placeholder="10/25/2012" title="Format of the date of Birthday ex:mm/jj/aaaa 03/13/1999" name="{{ item.product_id }}" value="{{ cart.attributes.product.product_id }}">
</p>
<p class="cart-attribute__field">
<label>Child Gender</label><br>
<select required class="required" id="{{ cart.attributes.product.product_id }}" name="Gender{{ cart.attributes.product.product_id }}">
<option value="Girl"{% if cart.attributes.product.product_id == "Girl" %} selected{% endif %}>Girl</option>
<option value="Boy"{% if cart.attributes.product.product_id == "Boy" %} selected{% endif %}>Boy</option>
</select>
</p>
</div>
{% endfor %}
{% endif %}
Thank you so much for the reply.
Sadness it doesn't show anythings.
Can you please provide your store URL ? So that I can check this in detail
Just to edit to give more info:
Currently on the website I show 1 voucher per product_ID detected.
But i would like to create something better to show this one when the product_original_price == 0 or equivalent 🙂
Is someone has an idea ?
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024