[Dawn Theme] How To Add Custom Input Field (Specific Products and Collections)

If you are a Shopify store owner, then you know that there is a lot of flexibility when it comes to customizing your store. Sometimes, though, you may need a little bit more help to make the changes that you want. In this blog post, we will show you how to add a custom input field to products and collections. This will allow you to type in specific information for each product or collection. In this Shopify tutorial, we will show you how to do just that! This process is fairly simple and can be completed in a few minutes. Let’s get started!

Add following Code in main-product.liquid file

<p class="line-item-property__field">
<label for="childsName">Child's Name:</label>
<input id="childsName" type="text" name="properties[Child's Name]" form="product-form-{{ section.id }}">
</p>

Custom Field for Specific Product

{% If product.title == "Your product name" %}
<p class="line-item-property__field">
<label for="childsName">Child's Name:</label>
<input id="childsName" type="text" name="properties[Child's Name]" form="product-form-{{ section.id }}">
</p>
{% endif %}

Custom Field for Specific Collection

{% for collection in product.collections %}
  {% if collection.title contains "New Collection" %}
    
	<p class="line-item-property__field">
<label for="childsName">Child's Name:</label>
<input id="childsName" type="text" name="properties[Child's Name]" form="product-form-{{ section.id }}">
</p>
  
  {% endif %}
{% endfor %}
5/5 - (17 votes)

About

2 thoughts on “[Dawn Theme] How To Add Custom Input Field (Specific Products and Collections)”

  1. Thank you! My code didn’t tag the “if” in the Custom Field for Specific Product but after a couple mins of troubleshooting and googling, I got it. I was also able to successfully move the customization box after trial and error with the code (I have no idea how to read code). Overall, very helpful and pretty easy to follow. This was a lifesaver, thanks again!

Leave a Comment

Your email address will not be published. Required fields are marked *