Adding a checkbox to the checkout page

Solved
jraymond12
New Member
3 0 0

I'm trying to add a checkbox to my checkout page (the checkbox text would be: Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?)

I've gone through the forums and found a way to add it to the code. It worked by adding it to the code but when I sent through a test order, it does not show on my end whether or not the customer selected the checkbox. 

Is there another way of doing this, so that as the shop owner I can see whether or not the customer has selected the checkbox? 

Accepted Solution (1)

Accepted Solutions
Alpha_Geek
Excursionist
15 4 1

This is an accepted solution.

Hi jraymond12,

Please go to 'Online store' -> 'Actions' -> 'Edit code' and add this to your cart.liquid file in between the <form> </form> tags. It will appear where you place the code. And this will show up on each order in the top right:

<p class="cart-attribute__field">
  <input type="hidden" name="attributes[Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?]" value="No">
  <input type="checkbox" name="attributes[Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?]" value="Yes"{% if cart.attributes["Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?"] == "Yes" %} checked{% endif %}>
  <label>Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?</label>
</p>

 

View solution in original post

Replies 4 (4)
Alpha_Geek
Excursionist
15 4 1

This is an accepted solution.

Hi jraymond12,

Please go to 'Online store' -> 'Actions' -> 'Edit code' and add this to your cart.liquid file in between the <form> </form> tags. It will appear where you place the code. And this will show up on each order in the top right:

<p class="cart-attribute__field">
  <input type="hidden" name="attributes[Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?]" value="No">
  <input type="checkbox" name="attributes[Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?]" value="Yes"{% if cart.attributes["Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?"] == "Yes" %} checked{% endif %}>
  <label>Do you need an alibi ln your package. In the form of Congratulations on winning this ltem'?</label>
</p>

 

jraymond12
New Member
3 0 0

Thank you Alpha_Geek! That worked perfectly. 

booshdaboo
New Member
2 0 0

I am also trying to do this but I don't have the <form> </form> tags.

This is the code I have-

 

{% comment %}
The contents of the cart.liquid template can be found in /sections/cart-template.liquid
{% endcomment %}

{% section 'cart-template' %}

booshdaboo
New Member
2 0 0

Finally got it. Tried to delete last comment but cannot, so please just ignore 🙂