Everformat Product Options · Shopify how-to
How to make a custom field required in Shopify
A required field stops Add to cart until the shopper fills it in, so you never get an engraving order with no text. Here is the theme code way, where it leaks, and how our app closes the gaps.
Method 1: the required attribute (theme code)
- Add your field in a Custom Liquid block on the product page, inside the Product information section.
- Add the required attribute to the input, as below. When the shopper clicks Add to cart with the field empty, the browser shows its own "Please fill out this field" message and does not submit.
- Test it in your theme. Some themes add to cart with JavaScript in a way that skips the browser’s check, so try an empty field before you rely on it.
{%- assign form_id = 'product-form-' | append: section.id -%}
<label for="name-{{ section.id }}">Name to print</label>
<input id="name-{{ section.id }}" type="text" name="properties[Name]"
form="{{ form_id }}" maxlength="20" required>Where the required attribute leaks
The Buy it now button goes straight to checkout and does not wait for your field. Untick "Show dynamic checkout buttons" in the Buy buttons block on products that need an answer.
Quick add buttons on collection and home pages add the product without opening the product page, so the shopper never sees the field. Turn quick add off in the product grid settings, or accept that those orders arrive without an answer.
Method 2: Everformat Product Options (no code, free)
- Install Everformat Product Options from the Shopify App Store and click Turn on automatic embed.
- Click Create option set, add a field, and tick Required. Required fields are on the Free plan.
- Choose which products get the set. On those products, Add to cart waits for an answer and shows a message next to the field.
- The app also hides Buy it now on products with a required field, and quick add buttons on collection pages send the shopper to the product page instead of adding the item without an answer.
Everformat Product Options is our Shopify app for this. The Free plan covers 3 option sets with up to 10 fields each.
Get it on the Shopify App Store About the app
Questions
Can I change the "required" message?
With the HTML attribute, the message comes from the browser and is hard to change. The app shows its own message next to the field.
Can a field be required only sometimes?
Yes, on Pro. A field with a show-when rule is only required while it is showing, for example engraving text only after "Add engraving" is ticked.