Where to paste it
- In your Shopify admin, go to Online Store, Themes, then Customize on your theme, and open a product page.
- In the product information section, add a Custom Liquid block where you want the field, for example above the Buy buttons.
- Paste the code and save. The
form="{{ product_form_id }}"part ties the field to the product form in Dawn and themes built like it. If your theme names its form differently, paste the code inside the product<form>in the theme code instead and remove that attribute. - Add the product to the cart and check the answer shows on the cart, the checkout and the order in your admin.
Copy your theme first (Themes, then the three dots, then Duplicate) so you can go back if something breaks.
What the code can't do
- Required isn't reliable. The code adds the browser's
requiredrule, but many themes, Dawn included, turn browser checks off on the product form, and dynamic checkout buttons like Buy it now skip the form. So a "required" field can still be left empty. - Theme updates. The field lives in your theme. A new theme or some theme updates won't carry it over, so you add it again.
- One product type at a time. To show different fields on different products, you need a template per product type or Liquid conditions in the code.
- No show-when logic. Showing a text box only after "Engrave: yes" needs extra JavaScript.
Doing it with Everformat Product Options
We built Everformat Product Options for exactly this job. You install it from the Shopify App Store, create the field, choose which products it appears on, and it shows on those product pages without you editing any theme code. The shopper's answer travels with the item to the cart, the checkout and the order. There is a free plan, and Pro is $9.99 a month.
For more detail, including a free theme-code method and engraving line limits with a live preview, see our Product Options guides.
Rather paste code yourself? Our free line item properties generator writes it for text, dropdown, radio, checkbox and date fields.
It can also charge extra for an option, like +$5 for engraving, and take a photo or file upload from the shopper, on any Shopify plan. The uploaded file is saved in your store's Shopify Files and linked on the order. Check the current plan details on the listing before you install.
In the app, a required field blocks Add to cart until it's answered and Buy it now is hidden on that product so it can't skip the field, fields can be assigned by product, collection or tag, and nothing is added to your theme code, so theme changes don't lose it.