How to add custom inputs in Shopify order from products?
2 min readNov 26, 2020
Update Cart-Template
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code. In the Sections directory, click
cart.liquid
orcart-template.liquid
. - Press
Ctrl + F
to open the search bar and search for{{ item.product.title }}
- On a new line below, paste the following code:
{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
{% for p in item.properties %}
{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}
{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
{% else %}
{{ p.last }}
{% endif %}
<br>
{% endunless %}
{% endfor %}
{% endif %}
5. Click Save.
Add custom form fields
- Go to your product template which you want to edit
- Find the code
type="submit"
in the file. This will be a submit button for add to cart form. - Make custom input’s like in below code, make sure you add the name as written below
properties[Custom Name which you want to show in order form]
<input name="properties[Name]" value="Karan" type="text" id="name">
<input name="properties[Location]" value="Punjab" type="text" id="Location">
<input name="properties[Message]" value="Don't forget to hit like" type="text" id="message">
4. Hit save.
5. Now when you add some product to the cart you will see these input values with the name inside properties, like the below image.
Thanks for reading & don’t forget to hit like if it helped you. Comment for any questions