How to add custom inputs in Shopify order from products?

Karan Goyal
2 min readNov 26, 2020

--

Update Cart-Template

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code. In the Sections directory, click cart.liquid or cart-template.liquid.
  3. Press Ctrl + F to open the search bar and search for {{ item.product.title }}
  4. 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

  1. Go to your product template which you want to edit
  2. Find the code type="submit" in the file. This will be a submit button for add to cart form.
  3. 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.

Screenshot of custom properties in shopify

Thanks for reading & don’t forget to hit like if it helped you. Comment for any questions

--

--

Karan Goyal
Karan Goyal

Written by Karan Goyal

Full Stack Developer, Top Rated on Upwork, Worked on 90+ jobs in past 9 months and all jobs are rated 5 stars, coding is fun, and always looking forward to code

No responses yet