Adding and retrieving cart attributes

Adding and retrieving cart attributes

Monck
Visitor
2 0 0

Hi all,

 

I am trying to add in a simple question which is responded to with radio buttons on my cart page. I have added the following code to main-cart-items.liquid:

<p class="cart-attribute__field">
<label>Skittles or Oreos</label><br>
<input required class="required" type="radio" name="attributes[Skittles or Oreos]" value="Skittles"{% if cart.attributes["Skittles or Oreos"] == "Skittles" %} checked{% endif %}> <span>Skittles</span><br>
<input required class="required" type="radio" name="attributes[Skittles or Oreos]" value="Oreos"{% if cart.attributes["Skittles or Oreos"] == "Oreos" %} checked{% endif %}> <span>Oreos</span><br>
</p>

This displays the following:

skittles.png

The functionality works perfectly on the cart screen but the problem is that when someone orders, I can't find where their selection is stored in the order information.

 

Help! Please!

Replies 2 (2)

sahilsharma9515
Shopify Partner
1257 163 241

Hi @Monck Welcome to the community!

 

You need to store the value in the "line_item" object so that you can see what customer has selected when they have completed their order, and once you store it in the line_item you can see customers selection under notes.

sahilsharma9515_0-1727950741681.png

 

Hopefully it will help you. If yes then Please don't forget hit Like and Mark it as solution!

 

Best Regards

Sahil

 

- Your

 Coffee Tip 

can create magic in coding ❤️❤️

- Need a Shopify Developer? CHAT ON WHATSAPP or EMAIL ME !


- Hopefully the solution will help you. If yes then Please hit

 Like 

and

 Mark it as solution! ❤️


Monck
Visitor
2 0 0
Thanks Sahil. Next question. How do I do this?

Sorry for all the questions, I'm a newbie!