How to add an engraving option to a Shopify product

Hura Product Showcase Builder

If you are selling the products that can be engraved, you’ll need to have an engraving option on your product page. This will be a field where the customer can enter the text that they want engraved and which will get attached to the order you receive.

In this article we’ll look at very clear and simple steps to add an engraving option to your product page.

It will take you only a few minutes to get your engraving product up and running.

You can edit your theme’s code by creating an alternate product page template that includes custom form fields, or line item properties. You can then apply your new template to any product for which you want to collect customization information from customers.

Step 1: Create a template that includes line item properties

To create a new product page template:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Templates directory, click Add a new template.
  4. Choose product from the drop-down menu, and name the template customizable:
  5. Click Create template. This creates a copy of your product.liquid template called product.customizable.liquid. The new file will open in the code editor.
  6. Find the following line of code:

    Replace it with
  7. Click Save.
  8. In the Sections directory, click Add a new section.
  9. Name your new section file product-customizable-template. Click Create section. Your new file will open in the code editor.
  10.  Delete all of the default code so that the file is empty. Copy all of the content from your product-template.liquid file (in the Sections directory), and paste it into your new product-customizable-template file.
  11.  Click Save.

Step 2: Create custom form fields

You can add as many custom form fields to your product page as you need. You can use the Shopify UI Elements Generator tool to easily generate the HTML and Liquid code for each form field that you want to add to your cart page. This tool was created by Shopify to help simplify the process of adding custom user interface elements, such as form fields and icons, to Shopify themes.

  1. Go to the Shopify UI Elements Generator.
  2. In the Set your form field section, select the type of form element that you want to use from the Type of form field drop-down menu:
  3. If you want your theme to prevent customers from adding a product to the cart before they have filled in your form field, check Required.
  4. You can see a preview of your form field in the Preview section:
  5. Copy the generated code from the box in the Grab your code section:

Step 3: Add custom form fields

To add custom form fields to your template:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Sections directory, click product-customizable-template.liquid.
  4. Find the code type="submit" in the file. This is part of the code for the Add to cart button. On a new line above the block of code that contains the Add to cart button, paste the form fields for your product customization:

    In the above example, the form field code adds an Engraving field where customers can enter text for a custom engraving. The line where you place the code determines where the form field will appear on your product page. You can experiment with putting the code in different places in the file.
  5. Click Save.

To make the new form fields appear on product pages, you need to set your customizable products to use the new product-customizable-template.liquid template that you created.

Step 4: Apply your new template to a product

To apply a template to a product:

  • From your Shopify admin, go to Products > All products.
  • Click the name of the product that will use your new template.
  • In the Theme templates section, choose product.customizable from the Product template menu.
  • Click Save.

The custom form fields that you created will now appear on that product’s page. Repeat the steps to enable the template on multiple products. You can use the bulk editor to enable your template on many products at once.

Step 5: Show customizations in the cart

If your theme doesn’t display customizations in the cart, then you can add some code to either your cart-template.liquid, or your cart.liquid file to check for line item properties and display them if they exist.

Show line item properties in the cart

To show product customization information in the cart:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Sections directory, click cart-template.liquid. If your theme doesn’t have a cart-template.liquid, then open the Templates directory and click cart.liquid.
  4. Find the line containing the code {{ item.product.title }}. On a new line below, paste the following code:
  5. Click Save.

Update links that remove items from the cart

Any links that remove items from your cart will need to be updated to work with custom line item properties:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Sections directory, click cart-template.liquid. If your theme doesn’t have a cart-template.liquid, then open the Templates directory and click cart.liquid.
  4. Find any a tag that has an href value starting with /cart/change.
  5. Change the full href value to href="/cart/change?line={{ forloop.index }}&quantity=0".
  6. Repeat these steps for every a tag in cart-template.liquid that has an href value starting with /cart/change.
  7. Click Save.

Update item quantity fields in the cart

Any fields that display item quantities in your cart will also need to be updated to work with custom line item properties:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Sections directory, click cart-template.liquid. If your theme doesn’t have a cart-template.liquid, then open the Templates directory and click cart.liquid.
  4. Find any input tag that has an name value of updates[{{ item.id }}].
  5. Change the full name value to name="updates[]".
  6. Repeat these steps for any input tag in cart-template.liquid that has an name value of updates[].
  7. Click Save.

Step 6: Show customizations in email templates

You can optionally also display line item properties in email notifications. This will let customers see their product customizations when they receive an email about their order.

  1. From your Shopify admin, go to Settings > Notifications.
  2. Click the name of the notification template that you want to add line item properties to.
  3. Find the following code:

    Replace it with:
  4. Click Save.

Repeat these steps for any other email notifications that you want to include line item properties.

Source: Shopify

Hura Theme Blocks

You may also like...

3 Responses

  1. laura kuschel says:

    Thank you so much for this amazing post! I could not have done personalization on Shopify without this post! It saved me! And it was so thorough and easy to understand. Great job! Thank you again.

  2. asdf says:

    Really good post, thank you. However, the “required” field in the UI Elements Generator does not seem to work. Customers can still proceed to checkout with a blank field, even when “required” is checked ad custom text field creation. Anyone have the same issue and found a solution?

  3. Chelsea says:

    Thanks so much for this! So helpful! Is it possible to add a second engraving option without it being attached to the first (and showing up on every product the first is on)? I have tried several things, would love some help on that!

Leave a Reply

Your email address will not be published. Required fields are marked *