Show a field when the item.original_line_price is 0 outside of the for cart.item

Solved
MarcPaul
Tourist
11 1 0

Hello!

hope everyone feel good

I have a question, I would like to show a field when the price of 1 or more line on the cart = 0

I found that :

 

 

{%- if item.original_line_price == 0 -%}
         <p class="cart-attribute__field">
              <label for="first-name">Full Name </label>
              <label>ex: Jhon Doe</label>
              <input required class="required" id="full-name" type="text" placeholder="Jhon Doe" title="Start by a Capslock ex: Jhon Doe" name="attributes[Full Name]" value="{{ cart.attributes["Full Name"] }}">
            </p>  
{%- endif -%}

 

 

This code works but only inside the {%- for item in cart.items -%} {%- endfor -%}
I would like the same but outside the "For".
 
The goal it's to create 1 custom field for each product = 0
If I put it on the for the custom for as the same name and in a fact can't be extract after because it replace the first value by the second (because the field has the same value).
I tried to create a for like that :

 

 

{% for i in (1..5) %}
  {% if i == 1 %}
    <p class="cart-attribute__field">
<label for="first-name">Full Name </label>
<label>ex: Jhon Doe</label>
<input required class="required" id="full-name{{ i }}" type="text" placeholder="Jhon Doe" title="Start by a Capslock ex: Jhon Doe" name="attributes[Full Name]" value="{{ cart.attributes["Full Name{{ i }}"] }}">
</p> 
  {% endif %}
{% endfor %}

 

 

it show me 2 times the same field with same value so "full-name1".
 
My goal it's just to show a field per product original price = 0.
 
Thank you
Hope all is enough clear for you!
 
 
0 Likes
MarcPaul
Tourist
11 1 0

Is there something wrong to having 0 reply ?

0 Likes
MarcPaul
Tourist
11 1 0

This is an accepted solution.

Thank you for your help!

I found the solution!

0 Likes