Theme guide
How to add a required custom text field to a Shopify product page
What you’ll need
The theme editor (to add a Custom Liquid block; no code editing)
How to get this: The theme editor
- Online Store › Themes › Edit theme (on a copy of your theme if you want to test first).
- Add section or Add block › Custom Liquid, paste the code, then Save.
Your settings for the feature (for example your free shipping amount or countdown end date)
Steps
- In the Liquid Snippet Studio choose Custom fields and type your label, like Name to engrave.
- Set the most characters, the example text and tick “shoppers must fill this in”.
- Go to Online Store › Themes › Customize › Products › Default product.
- Add block › Custom Liquid in Product information, paste, and drag it above Buy buttons.
- Save and try Add to cart with the field empty: the message shows and nothing is added.
Only some products
Choose “Only products with a tag” and tag those products, for example personalize. Every other product shows nothing, so one block on the default product template is enough.
The code, if you’d rather write it
The core of it is one input. The generator adds the form link, the required check, the counter and the error message around it.
<label for="engraving">Name to engrave</label>
<input id="engraving" type="text" name="properties[Name to engrave]" maxlength="20" form="product-form-{{ section.id }}">Related tools and guides
- Print them on packing slips
Packing Slip Builder
- Show them in the order confirmation email
Notification Email Snippets
- Export orders with line item properties
Orders Export