How to display order notes on cart for specific products only?

Solved

How to display order notes on cart for specific products only?

rak-nyc
Visitor
3 0 2

Hi everyone,

 

For the holiday season we are offering a personalized gift card, but only for select products. We plan to use Shopify's Order Notes field on the Cart page to enable customers to add their personalized note. 

 

Since this feature is only relevant to some products, Im hoping to display the notes field on cart only if an eligible product is in the cart. Logic in the cart's liquid like:

 

IF cart includes item 7625793917133 OR 7625793917156 OR 7625793917236 THEN show {{ Cart Notes }}

 

If anyone has done this before, or has an idea of the exact code to get this to work it would be helpful. thank u!

Accepted Solution (1)

PaulNewton
Shopify Partner
7722 678 1626

This is an accepted solution.

What the code would go varies by theme.

For the logic you would want to avoid hardcoding ids and either assign a tag to the product or a specific metafield, have them in a specific collection etc. 

So that as you add/remove products you are not automatically making the theme out of date.

 

Loosely a condition for checking tags would be as follow by adding to the item loop in the relevant cart templates (i.e. {% for item in cart.items %} )

Always backup themes before changing code.

{% if item.product.tags contains "gift note" %}
 {% comment %}Add cart note code below {% endcomment %}
 
{% endif %}

 

 If you need this customization done you can contact me, contact info in signature. Please provide context: post url, store url, theme name, problem description,etc. 

 

Good hunting.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Reply 1 (1)

PaulNewton
Shopify Partner
7722 678 1626

This is an accepted solution.

What the code would go varies by theme.

For the logic you would want to avoid hardcoding ids and either assign a tag to the product or a specific metafield, have them in a specific collection etc. 

So that as you add/remove products you are not automatically making the theme out of date.

 

Loosely a condition for checking tags would be as follow by adding to the item loop in the relevant cart templates (i.e. {% for item in cart.items %} )

Always backup themes before changing code.

{% if item.product.tags contains "gift note" %}
 {% comment %}Add cart note code below {% endcomment %}
 
{% endif %}

 

 If you need this customization done you can contact me, contact info in signature. Please provide context: post url, store url, theme name, problem description,etc. 

 

Good hunting.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org