Hey friends, welcome back! đ
Today, weâre tackling something that a lot of store owners and devs ask about: how to let customers personalize their products on Shopify. Whether thatâs engraving a name, uploading a photo, picking a custom size, or anything in between.
The good news? You donât need an app or a ton of code to do it. Weâre going to add custom fieldsâlike text inputs, dropdowns, checkboxes, radio buttons, and even file uploadsâright on the product page using Shopifyâs built-in system called line item properties.
By the end of this post, youâll know exactly how to set these up so customers can personalize products before adding them to the cart. And yepâit's all beginner-friendly and free.
Letâs jump in and make your product pages much more powerful! đ
â
â ïž Heads up: If you're using a paid theme, the steps in this tutorial should mostly workâbut just a heads up, some things like form IDs or class names might be a little different. So you might need to tweak a few things to match your themeâs setup. But donât worryâitâs nothing too crazy, and Iâll point you in the right direction as we go. đ
â
Create a backup for your theme
If you came from my learning Liquid post, you mightâve recognized this step đ However, if not, Iâll explain it to you.
Before making any changes to your storeâs code, always make sure to create a backup. We can easily do this by duplicating our theme. That way, youâll have a safety net and can switch back if anything doesnât go as planned.
To create a duplicate, head over to Online Store > Themes > Theme of Choice > ⊠> âDuplicateâ.
Nice! Now that weâve created a backup of our theme, weâre now ready to start making changes.
â
Choosing and creating custom field code
Now that weâve made a duplicate of our theme, we need to choose what field we want to add. There are many options that we can add. For example: short-text, long-text, radio buttons, select dropdown, checkboxes, and file upload.
Decide what field you want to add for your products. Do you need a short-text field for name engravings? Or do you need a long-text field for personalized messages?
After making the decision, weâre now going to grab the code we need for the custom fields. Lucky for us, Shopify has provided us a handy tool for adding custom input fields to our product pages. Itâs called the Shopify UI Elements Generator â Line Item Property.
This tool will allow us to create the exact code we need to copy to our product pages.
Hereâs how it works:
- On the left side, you choose the settings for your custom field.
- On the right side, youâll see a preview of how the field will look.
â ïž A quick note: The preview wonât perfectly match how itâll look in your actual store, but donât worryâwe can tweak the styling later with some basic CSS if needed.
To get started:
- Choose your field type. For example, Iâll go with short text for now.
- Add a label. This is the text that shows above the input boxâsomething like âEnter your nameâ.
- Check âRequiredâ if you want customers to fill this in before they can add the product to their cart.
- Check âShow at checkoutâ if you want this info to appear during checkout.
At the bottom of the page, youâll see your generated code. Go ahead and copy that code and save it somewhere for nowâweâll need it in just a bit.
đ And donât worryâweâre not going to mess with product.liquid! Iâve got a better (and safer) way to get this custom field onto your product page.
âBut wait, whereâs the file upload field?â you may ask. The UI Elements Generator doesnât have a file upload option out of the box, but hereâs a quick trick:
- Choose âText â Shortâ as your field type.
- Set your label and other settings as usual.
- Copy the code, then simply change type=âtextâ to type=âfileâ.
Just like that, we now have an upload file field. Awesome! đ„
Nice! Now youâve got the code for your custom input fieldâwhether itâs text, a drop-down, or even a file upload. Next up, Iâll show you exactly where and how to add it to your product page
â
Adding the custom field to the product page
To add the custom field to our product page, weâll be using one of the theme blocks named âCustom Liquid.â This block will allow us to add the new field without making changes to our themeâs code, simplifying the process.
To get started:
- Head over to Themes and then Customize.
- Next, navigate to the product page editor of the Theme Editor
- On the left-hand side, youâll find all the sections and blocks of the product page. Hover over the first section until you see ââ Add blockâ.
- Choose Custom Liquid.
- Paste the code we have generated using the generator. Click save.
Now, to make the custom field work and look seamless with your theme, we need to make some minor adjustments. This will apply to any custom field you add.
Adding the form attribute
We need to add the form attribute to our custom fields. This attribute will allow our custom fields to work properly.
To do this, simply add the following to your input field:
form="product-form-{{ section.id }}"
Below are the final examples for each field type after adding the form attribute. Your code should look like these examples.
For Paid Themes
If you are using a paid theme, the form attribute may look different. Hereâs how to find the correct code:
- Go to your product page in the theme editor and click on the main section to open its settings.
- In the top-right corner, click the three dots, then select Edit Code.
- (Donât worryâweâre not changing any code, just checking something.)
- In the Code Editor, use Ctrl + F (or Cmd + F on Mac) to search for:
- form, form_id, or product_form_id
- Look through the results and find an
<input>
tag with aform="..."
attribute.- You might also see
{% form 'product' ... id: the_form_id %}
â thatâs another clue!
- You might also see
Once youâve found the correct value, add it to your custom field inside the Custom Liquid blockâjust like in the examples.
Still stuck? Feel free to reach outâweâre happy to help or point you toward a developer đ
Text â Short (Added after â<input â)
<p class="line-item-property__field">
<label for="your-message">Your message</label>
<input form="product-form-{{ section.id }}" required class="required" id="your-message" type="text" name="properties[Your message]">
</p>
Text â Long (Added after â<textarea â)
<p class="line-item-property__field">
<label for="your-message">Your message</label>Â
<textarea form="product-form-{{ section.id }}" required class="required" id="your-message" name="properties[Your message]"></textarea>
</p>
Radio Buttons (Added after each â<input â)
<p class="line-item-property__field">Â Â
<label>Your message</label><br>Â Â
<input form="product-form-{{ section.id }}" required class="required" type="radio" name="properties[Your message]" value="Option 1"> <span>Option 1</span><br>Â Â
<input form="product-form-{{ section.id }}" required class="required" type="radio" name="properties[Your message]" value="Option 2"> <span>Option 2</span><br>Â Â
<input form="product-form-{{ section.id }}" required class="required" type="radio" name="properties[Your message]" value="Option 3"> <span>Option 3</span><br>
</p>
Select (Added after â<select â)
<p class="line-item-property__field">Â
<label>Your message</label><br>Â
<select form="product-form-{{ section.id }}" required class="required" id="your-message" name="properties[Your message]">Â Â
<option value="Option 1">Option 1</option>Â Â
<option value="Option 2">Option 2</option>Â Â
<option value="Option 3">Option 3</option>
</select>
</p>
Checkbox (Added after every â<input â)
Checkbox group (Added only on â<input â with type=âhiddenâ)
<p class="line-item-property__field">Â
<label>Your message</label><br>Â
<input required class="required" type="checkbox" id="Option-1" hidden-data="Your-message" onchange="fillHidden('Your-message')" value="Option 1"><label for="Option-1">Option 1</label><br>Â
<input required class="required" type="checkbox" id="Option-2" hidden-data="Your-message" onchange="fillHidden('Your-message')" value="Option 2"><label for="Option-2">Option 2</label><br>Â
<input required class="required" type="checkbox" id="Option-3" hidden-data="Your-message" onchange="fillHidden('Your-message')" value="Option 3"><label for="Option-3">Option 3</label><br>Â
<input form="product-form-{{ section.id }}" type="hidden" id="Your-message" name="properties[Your message]">Â
<script>/* Code hidden so that the code block doesn't get unnecessarily long*/</script>
</p>
File Upload (Added after â<input â)
<p class="line-item-property__field">Â
<label for="your-message">Your message</label>Â Â
<input form="product-form-{{ section.id }}" required class="required" id="your-message" type="file" name="properties[Your message]">
</p>
Testing our custom field
Now itâs time to test our custom field. This is important before we move on to styling it.Â
To start:
- Go to your product page where the new field is added.
- Use the custom field, then add the product to your cart.
- Go to the checkout page by doing a test checkout
At checkout, you should see your new custom field below the product name. đ„If you really want to make sure itâs working, do a test order and check the order details. The new field should show up below the order item đ
If the field isnât showing, double-check the following:
- Does your new field have the form attribute?
- Does your new field have the âshow at checkoutâ set to true when you were creating the field using the UI Elements Generator?
- If youâve set the âshow at checkoutâ to be false, the only way to confirm it is by doing a test order.
Doesnât work? Feel free to reach outâweâre happy to help or point you toward a developer đ
Styling our custom field
Woohoo đ„ł We now have our custom field working! Itâs now time to style it! Luckily for us, this step isnât too complicated. We just need to use our themeâs CSS to style our inputs.
â ïž This step will only work for text fields, as that is the only available built-in styling for free themes. For paid themes, donât worry; Iâll do my best to point you in the right direction đ
- Weâll need to add
<div class=âfieldâ>
before our<input>
or<textarea>
code. - Then, add
</div>
after the<input>
or</textarea>
code. For example:
<div class=âfieldâ><input form="product-form-{{ section.id }}" âŠ></div>
<div class=âfieldâ><textarea form="product-form-{{ section.id }}" âŠ></textarea></div>
- Then, after adding the
<div>
code, weâll need to add the CSS class to our<input>
or<textarea>
. The code to add isclass=âselect__selectâ
.
 <div class=âfieldâ><input class=âselect__selectâ form="product-form-{{ section.id }}" âŠ></div>
<div class=âfieldâ><textarea class=âselect__selectâ form="product-form-{{ section.id }}" âŠ></textarea></div>
For Paid Themes
If you are using a paid theme, the code to add will look different. Hereâs how to find the correct code:
- Look for an existing input field in your theme (contact form, newsletter, login, etc.).
- Right-click on it and then click on Inspect Element or Inspect. This will let you see the pageâs code, which contains the
<input>
and the CSS class to copy. - In the inspector, you will see the
<input>
with its attributes, such as form and class. This is our clue! - Copy the class over to your new field and test it out!
- Keep an eye out for a
<div>
element before the<input>
. That is also part of the code to copy to your custom field. Copy the structure and idea behind it to your custom field and then test it out! You can also refer to the instructions for the free theme above to get an idea of what the result should be.
Still stuck? Feel free to reach outâweâre happy to help or point you toward a developer đ
Congratulations! Youâve now added a custom field to your product page, styled it, and made sure it works! đ„ł Pat yourself on the back for this one; you did a really good job đ„
Wrapping Up
And thatâs it! đ
In this post, we walked through how to add custom fields to your Shopify product pages using line item propertiesâall without installing any apps or digging deep into complex code. Whether you added a simple text input, a dropdown, or even a file upload field, you now know how to:
- Choose and generate the right input field
- Add it safely to your product page
- Test that it works just like you'd expect
- Give it a bit of styling to match your storeâs vibe
Custom fields are a great way to offer personalized products and give your customers more control at checkoutâand now youâve got the tools to do just that đ„ł
If you found this helpful, feel free to check out the rest of the blog for more Shopify tips and tutorials. If you are up for a challenge, I suggest my previous tutorial on adding a size chart to the product page! Or check out my free course on Shopify Speed Optimization.
As always, happy building, and Iâll catch you in the next one! đ