<p>I think you can do something like;</p>

<pre><code>{% if product.type('products') %}
    code to show notes field
{% endif %}
</code></pre>

<p>See the product model docs here <a href="https://craftcommerce.com/docs/product-model" rel="nofollow noreferrer">https://craftcommerce.com/docs/product-model</a></p>

<p>The note attribute <em>is</em> part of the lineitem model so you should be able to show it. </p>

<p><a href="https://craftcommerce.com/docs/line-item-model#note" rel="nofollow noreferrer">https://craftcommerce.com/docs/line-item-model#note</a></p>

<p>The following should work.</p>

<pre><code>{% for item in order.lineitems %}
    {{ item.note }}
{% endfor %}
</code></pre>

<p>You could try naming your input field like so;</p>

<pre><code>&lt;input class="form-control" type="text" placeholder="Productsort"  name="item[note]" value="{{ item.note }}" required&gt;
</code></pre>

<p>I'd need to test this though. I've done something along these lines but can't remember exactly what I did.</p>

CC BY-SA 3.0
2018-02-10T12:43:46.757Z
That is what was my first thought too. But the note element is in the cart.lineItems and maybe that is why it is not working?
John Stevens
CC BY-SA 3.0
2018-02-10T12:47:25.207Z
I misunderstood what you were trying to do. You want to show a note that has already been added to the item within the cart view right?
foamcow
CC BY-SA 3.0
2018-02-10T12:49:11.210Z
Yes that is correct.
John Stevens
CC BY-SA 3.0
2018-02-10T12:57:12.557Z
I've updated my answer
foamcow
CC BY-SA 3.0
2018-02-10T13:07:14.123Z
Actually, you're doing it right. Is the problem that the note isn't being stored or is it simply that you are having problems with the condition to show/hide the note field?
foamcow
CC BY-SA 3.0
2018-02-10T13:15:42.667Z
Problem with the show hide. Storing of data works fine.
When Adding that if statement, nothing is shown.
John Stevens
CC BY-SA 3.0
2018-02-10T11:45:33.203Z
2018-02-10T13:02:16.837Z
2018-02-10T13:02:16.837Z
foamcow
<p>In my shop, I have two different kinds of products.type items and my products have variants.</p>

<p>For one of products type, I would like to show the note field in the cart.</p>

<p>My product types are:</p>

<ul>
<li>products </li>
<li>options</li>
</ul>

<p>For product type options, I don't want to show the note field.</p>

<p>How can I set this up? </p>

<p>Tried this without success.</p>

<pre><code>{% for item in cart.lineItems %}
&lt;form method="POST"&gt;
&lt;input type="hidden" name="action" value="commerce/cart/updateLineItem"&gt;
&lt;input type="hidden" name="lineItemId" value="{{ item.id }}"&gt;

{% if product.type('products') %}
&lt;input class="form-control" type="text" placeholder="Productsort"  name="note" value="{{ item.note }}" required&gt;
{% endif %}
&lt;input class="form-control" type="submit" class="button" value="Bijwerken"/&gt;
&lt;/form&gt;
{% endfor %}
</code></pre>

<plugin-craftcommerce>
Notes field only for certain product types
# Notes field only for certain product types

(Asked by: username_0 on 2018-02-10)

In my shop, I have two different kinds of products.type items and my products have variants.
For one of products type, I would like to show the note field in the cart.
My product types are:

products 
options

For product type options, I don't want to show the note field.
How can I set this up? 
Tried this without success.
{% for item in cart.lineItems %}




{% if product.type('products') %}

{% endif %}


{% endfor %}

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_1 on 2018-02-10. Score: 1

I think you can do something like;
{% if product.type('products') %}
    code to show notes field
{% endif %}

See the product model docs here https://craftcommerce.com/docs/product-model
The note attribute is part of the lineitem model so you should be able to show it. 
https://craftcommerce.com/docs/line-item-model#note
The following should work.
{% for item in order.lineitems %}
    {{ item.note }}
{% endfor %}

You could try naming your input field like so;


I'd need to test this though. I've done something along these lines but can't remember exactly what I did.

> **Comments:**
> **username_0**: That is what was my first thought too. But the note element is in the cart.lineItems and maybe that is why it is not working?  
> **username_1**: I misunderstood what you were trying to do. You want to show a note that has already been added to the item within the cart view right?  
> **username_0**: Yes that is correct.  
> **username_1**: I've updated my answer  
> **username_1**: Actually, you're doing it right. Is the problem that the note isn't being stored or is it simply that you are having problems with the condition to show/hide the note field?  
> **username_0**: Problem with the show hide. Storing of data works fine. When Adding that if statement, nothing is shown.  

---

