Check out my Youtube channel

Add a Text Field To Products in Shopify 2.0 - Gift Notes, Engravings, Customizable Products, etc...

This is a brief summary of the video above. You can watch it for the full tutorial.

The finished code (for Dawn):

<label for="message" class="form__label">Message:</label>
<div class="field">
  <textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]"form="product-form-{{ section.id }}"></textarea>
</div>

What & Why

Many Shopify themes already have a text field built-in on the CART page - usually called ‘Order Notes’. This attaches a note to the entire order which you can then see in your Shopify orders page.

There are cases when this isn’t suitable, such as when you sell customizable products. E.g:

  • Engravings or products with the name of the recipient on them.
  • Flowers, birthday gifts, corporate gifts, with a gift message attached to each product.

For example, a corporate client could order 10 different gifts in one order, with a different gift message for each gift.

So when the order comes through - you need to see this text attached to the product, rather than the entire order.

This tutorial is the easiest way to do it with just one or two text fields on a Shopify 2.0 theme like Dawn. We will be using the “custom liquid” block type, which is only available on modern themes.

Also, if you want to give a customer more options to customize the product, with different field types like checkboxes or dropdowns, let me know and I can make that video.

Step 1 - Add a custom liquid block

  • Go into your theme editor, and navigate to your product page.
  • Open the dropdown called product Information
  • Add block > Custom liquid

Step 2 - Create a basic textarea

<textarea id="message" placeholder="Message" name="properties[Message]"></textarea>
  • Firstly choose what you want to call it. I’m using “message” to keep it generic but for you it might be “engraving”, “gift-note” or whatever you want.
  • We add an id of “message” in lower case (or whatever word you’re using).
  • We add a placeholder with proper sentence case - people see this as the preview on the field.
  • Most important part: We add name=“properties[Message]”. Whatever you called your field goes in the square brackets.
  • The properties[] part is always the same. This is what connects the field to the Shopify admin. This is the heading that you will see in the order.

If you’re using Dawn, you just need to add the following attribute to your textarea:

form="product-form-{{ section.id }}"

The complete textarea looks like this so far:

<textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]"form="product-form-{{ section.id }}"></textarea>

If you’re not using Dawn, you need to take a look at the form code using the inspector, and find the form ID. You can find the form by right-clicking anywhere around the add-to-cart button, and clicking Inspect.

The form HTML will look something like this:

Here you can see the ID is product_form_6802660622380

We also get a hint that the number on the end is not the section id as on Dawn theme, but rather its the product id, because lower down you can see data-productid and the same number.

From this we can deduce that we should change the form id from the Dawn example to something like this:

form="product_form_{{ product.id }}"

Step 4 - Make it look nicer

Adding classes that your theme uses for CSS will immediately make this field look like part of your theme

  • You can find the classes you should use by inspecting the contact form on your contact page. The message field there is a textarea, so you can sopy those classes.
  • For Dawn, the classes for the textarea are text-area and field__input
  • For Dawn, we should also wrap the textarea in a div with class of “field”

Here is the full code so far:

<div class="field">
  <textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]"form="product-form-{{ section.id }}"></textarea>
</div>

Step 5 - Add a field label

This appears above the field.

<label for="message" class="form__label">Message:</label>

  • The ‘for’ attribute should match the id of the textarea.
  • For Dawn, the class is "form__label".

The finished code (for Dawn):

<label for="message" class="form__label">Message:</label>
<div class="field">
  <textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]"form="product-form-{{ section.id }}"></textarea>
</div>

Want posts like this in your inbox? Subscribe to the newsletter.

Comments

19 comments
  • Jordan

    Hey! I love this tutorial. What I'm struggling with is that I can't get the custom.liquid to be placed within the Product Information Template. I can place it above or below but I can't get it inside the Product Section itself. Have you encountered this?

    I have "add section" but I don't have "add block" - Im using Dawn


  • Sarah Bayly

    AMAZING!!!! I've spent days trying to fix this after a theme update, and did it within 10 minutes using your instructions (Using Canopy theme).

    Not only did your instructions make it really easy, I love how you explained what certain elements meant. THANK YOU!!!!!!


  • Paul @Jetcast

    Thanks, is there anyway to make this appear just for selected products?


  • Edvards

    Hi, works grate thanks.
    How can I add condition for writing only numbers and exactly 15 characters, not less not more.


  • wamiq

    i tried the method but the info not shown in orders


  • Sofia

    Hi! Thank you so much for this post! It was so helpful!!! I also followed your tutorial on Youtube. My question is, how do I add the message box just to certain products but not others? For example, I sell greeting cards (so I need the message box) but I also sell prints and earrings and they don't need the personalisation. Also, I used Dawn for my shop. Thank you!


  • Eric W

    How can I make this field required?


  • ellesee123

    Thanks so much!
    I have many selectors on my product page so I wanted it to be smaller. I played around with the code a bit. It's still a bit wider than I wanted but the height is great:

    <label for="message" class="form__label">Order Note and/or Gift Message:</label>
    <div class="field">
    <input id="message" type="“text”" class="field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
    </div>


    1 reply
    • srp

      Hi. I used your code above to make my message box smaller, yes, the height is great but my box is like an inch or more wider than my "Add to cart" button. Did you find a fix for this? Thanks advance


      1 reply
      • ellesee123

        I probably left it as-is...I can't find any record of a change, but mine is just a tad longer than the add-to-cart button. I'm assuming it would need some custom css and is probably fairly straightforward but I forgot and didn't look into how to do it. Good luck!


  • Dan

    Hello I tried this and it worked for the products I needed customized, but when I was testing it and entry the info or name I want on my product, then I go to the cart and it doesn't show me the information. So when I customer places an order an entered a name it won't show on the order or cart. How do I fix this?


  • Paolo Falconi

    Is there a way on how to do it on "origin" theme? im strugglin because it doesnt appear the message when I add to cart


  • Anna

    I plugged the code in on my products page and the text box shows but not in the cart or at checkout. What am i doing wrong?
    Thank you.


  • Pierre-Axel

    Hello ! Thanks Ed ! That's awsome and super clear.
    Could you help us with another tuto. How could we add a message on DAWN at the Cart step? As on your demo video.
    Your tuto in live here :)
    https://get-quark.com/produ...


  • dan

    using the following code with the larger nicer looking box. but i need it to be required :

    <label for="message" class="form__label">Message:</label>
    <div class="field">
    <textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
    </div>

    tried amending it to this:

    <label for="message" class="form__label">Message:</label>
    <div class="field">
    <textarea required="" class="required" id="message" class="text-area field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
    </div>

    but the box display messes up. Please help


  • dan

    using this code with the extra nice looking box: <label for="message" class="form__label">Message:</label>
    <div class="field">
    <textarea id="message" class="text-area field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
    </div>

    tried to add required to it (code below)

    <label for="message" class="form__label">Message:</label>
    <div class="field">
    <textarea required="" class="required" id="message" class="text-area field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
    </div>

    but the box is size messes up. please can someone help


    2 replies
    • Lisa Antler

      <label for="message" class="form__label">Message:</label>
      <div class="field">
      <textarea required=" class=" required"="" id="message" class="text-area field__input" placeholder="Message" name="properties[Message]" form="product-form-{{ section.id }}"></textarea>
      </div>

      There you go, fixed it for you. Thanks for sharing I was able to use it. It works great and without the extra " works perfect.


  • Eirian

    Hi, I hope you can help me please. I'd like that the customer would need a required option to complete both fields before submitting to cart. How do I add a required field to the name and date field? What is the coding that I need to add.
    My coding now is:

    <label for="name" class="form__label">Name</label>

    <div class="field">

    <textarea id="name" placeholder="Type the NAME to be embroidered on this item" name="properties[Name to be embroidered]" form="product-form-{{ section.id }}"></textarea>

    </div>

    My page looks like this. It is not live at the moment.
    https://1qpr6issz7bxoiyp-69...

    Thank you in advance.
    Eirian


  • Ajit Goel

    I added the custom liquid control to the product page and added the following code to the product_form.js file but the form tag does not render. I am using the Refresh theme and the same form tag is used in the next quantity control in main_product.liquid file. Would you have an input why? My website url is here

    product_form.js

    var inputs = document.getElementsByTagName("input");
    for(var i = 0; i < inputs.length; i++) {
    if(inputs[i].name.indexOf('properties') == 0) {
    formData.append(inputs[i].name, inputs[i].value)
    }
    }
    config.body = formData;

    product page's custom liquid control:

    <label for="personalization">Personalization:</label>
    <div class="field">
    <textarea rows="10" class="text-area field__input" id="personalization" placeholder="Personalization" type="text" name="properties[Personalization]" form="{{ product_form_id }}"></textarea>
    </div>


    1 reply
    • Ajit Goel

      I was able to figure it out. I changed the form value above to product-form-{{ section.id }}


  • Joris

    I got the concept and used it for radio buttons, adjusted to the dawn theme style. Great! Now I add it to the cart, (still working) and finish the test purchase. I can see it in the orders overview that the label is there. (so I got that). Now I try to export my orders and I cannot find the label that was originally created in the export file... Any idea how to work around that one? I'd need it in the export file (I wouldn't ask otherwise). Thanks for all the information and the clear material! Great stuff ;-)


    1 reply
    • Ashley Lynn Kriebel

      I'm having this same issue... I have not been able to find a resolution for it yet and was really hoping it was here.


  • Selman Bilgen

    Thank you for the tutorial. When I use the finished code, I cannot see the place holder text. After deleting class="text-area field__input" , I can see it but I don't know why. Any ideas, please?


    1 reply
    • SC

      I'm having the same issue. I deleted class="text-area field__input" as Selman suggested and I'm able to see it as well. I'm also using a Dawn theme.


  • horse

    Will it have to be on every product or is there a way to hide it on other products


    1 reply
    • Eduard Fastovski

      You can make a separate template called "gift product" or something, and add the text field block. Then apply the template only to products that you want to have the text field.
      Alternatively, wrap the code in an if statement, like this:
      {% if product.handle == 'your-product'%} your code {% endif %}


      2 replies
      • Michele Wandke

        Ok, I found your other video and I think I got it. I really don't know what exactly I did, but it works 😊 Thank you!!!


      • Michele Wandke

        How do you do this and where?