Product pages - Get customization information for products

TyW
Community Manager
Community Manager
418 40 1141

You can collect customization information for products using line item properties. Line item properties are custom form fields that you can add to the product page, allowing customers to make choices or add information about a product. For example, if you offer product engraving, then you can use line item properties to let customers enter the text that they want engraved on the product.

 

custom01.jpg

 

Tip: Line item properties are different from order notes and cart attributes. Order notes, which are available in every free Shopify theme, let you capture special instructions on how to prepare and deliver an order. Cart attributes are specified by customers on the cart page, and are used to record additional information about an entire order.

TyW | Online Community Manager @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Replies 270 (270)
TyW
Community Manager
Community Manager
418 40 1141

Sectioned themes

Use an app to collect customization information for products

You can install a free or paid product customization app from the Shopify App Store to easily add custom fields to your product page.

Edit your theme code to collect customization information for products

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.

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:

      custom02.jpg
    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:

      {% section 'product-template' %}

       

      Replace it with:

      {% section 'product-customizable-template' %}

       

    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.

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:

    custom03.jpg

  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:

    custom04.jpg

  5. Copy the generated code from the box in the Grab your code section:

    custom05.jpg

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:

    custom06.jpg

    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.

Apply your new template to a product

To apply a template to a product:

  1. From your Shopify admin, go to Products > All products.
  2. Click the name of the product that will use your new template.
  3. In the Theme templates section, choose product.customizable from the Product template menu.
  4. 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.

Allow file uploads

If you create a form field input with type="file", then the customer's browser will show a file upload button for that form field. As a store owner, you can view any files that your customers upload. Letting customers upload files allows for some creative store ideas — like printing customer artwork onto canvas or accepting custom graphics to print on clothing.

If the form in your product-template.liquid contains a file upload field, the form tag in your customizable product template must have the attribute enctype="multipart/form-data".

Note: File uploads will work only on a page style cart, and are not compatible with cart drawers or cart popups. To change your cart style, go to the theme editor.

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:

    {% assign property_size = item.properties | size %}
    {% if property_size > 0 %}
      {% for p in item.properties %}
        {% assign first_character_in_key = p.first | truncate: 1, '' %}
        {% unless p.last == blank or first_character_in_key == '_' %}
          {{ p.first }}:
          {% if p.last contains '/uploads/' %}
            <a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
          {% else %}
            {{ p.last }}
          {% endif %}
          <br>
        {% endunless %}
      {% endfor %}
    {% endif %}
  5. Click Save.

This code checks each line item to see if it has any line item properties, and displays them if they exist.

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 a 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 a name value of updates[].
  7. Click Save.

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:

    {{ line.title }}
    Replace it with:

    {{ line.title }}{% for p in line.properties %}{% unless p.last == blank %} - {{ p.first }}: {{ p.last }}{% endunless %}{% endfor %}
  4. Click Save.
  5. Repeat these steps for any other email notifications that you want to include line item properties.

Hide line item properties (optional)

Line item properties that you have built into your customizable product templates are visible on your product pages and, if you have customized your cart code, on your cart page as well. Line item properties are also visible on the checkout page. There might be times when you do not want a line item property to be visible to the customer, for example, if you want to attach some internal information (such as a bundle ID or tracking number) to a product.

If you want a line item property to be hidden on the cart or checkout pages, then you can place an underscore _ at the beginning of its name value. For example, the name value for an internal Bundle ID might look like this:

name="properties[_bundle_id]"

If you did not use the code in this tutorial to show line item properties (or customizations) in the cart, then your theme code might not include the code that keeps line item properties with name values beginning with an underscore hidden. To modify your theme code to hide line item properties in the cart, you can add the following lines of code to your cart-template.liquid or cart.liquid file:

{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}

The results should look similar to this:

{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
  {% for p in item.properties %}
    {% assign first_character_in_key = p.first | truncate: 1, '' %}
    {% unless p.last == blank or first_character_in_key == '_' %}
      {{ p.first }}:
      {% if p.last contains '/uploads/' %}
        <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
      {% else %}
        {{ p.last }}
      {% endif %}
    {% endunless %}
  {% endfor %}
{% endif %}

Showing line item properties at checkout.

Line item properties will only be visible to customers during checkout if they are stored as a string. Numbers will be hidden, though they will still be tied to the order and show up in the Admin > Orders screen. For example:

  • line_item_prop: "1234" (will be visible on the Order and during checkout)
  • line_item_prop: 1234 (will be visible on the Order and hidden during checkout)

For context, this was introduced as a feature because line item properties were often used to store IDs which were not intended to be customer-facing. So theme developers can hide line item properties during checkout by storing them as an integer or a string with an underscore at the beginning.

TyW | Online Community Manager @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

TyW
Community Manager
Community Manager
418 40 1141

 

Non-sectioned themes 

 

 

 

Use an app to collect customization information for products

 

 

You can install a product customization app from the Shopify App Store to easily add custom fields to your product page.

 

 

Edit your theme code to collect customization information for products

 

 

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.

 

 

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:

    custom02.jpg
  5. Click Create template. This creates a copy of your product.liquid template called product.customizable.liquid.

 


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:

    custom03.jpg

  3. Check Required if you want your theme to prevent customers from adding a product to the cart before they have filled in your form field.
  4. You can see a preview of your form field in the Preview section:

    custom04.jpg

  5. Copy the generated code from the box in the Grab your code section:
    custom05.jpg

 

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 Templates directory, click product.customizable.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:

    custom06.jpg

    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.liquid template that you created.

 

 

Apply your new template to a product

 

 

To apply a template to a product:

  1. From your Shopify admin, go to Products > All products.
  2. Click the name of the product that will use your new template.
  3. In the Theme templates section, choose product.customizable from the Product template menu.
  4. 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.

 

 

Allow file uploads

 

 

If you create a form field input with the attribute type="file", then the customer's browser will show a file upload button for that form field. As a store owner, you can view any files that your customers upload. Letting customers upload files allows for some creative store ideas — like printing customer artwork onto canvas or accepting custom graphics to print on clothing.

 

If the form in your product-template.liquid contains a file upload field, the form tag in your customizable product template must have the attribute enctype="multipart/form-data".

Note: File uploads will work only on a page style cart, and are not compatible with cart drawers or cart popups. To change your cart style, go to the theme editor.

 

 

Show customizations in the cart

 

 

If your theme doesn't display customizations in the cart, then you can add some code to 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 Templates directory, click cart.liquid.
  4. Find the line containing the code {{ item.product.title }}. On a new line below, paste the following code:

    {% assign property_size = item.properties | size %}
    {% if property_size > 0 %}
      {% for p in item.properties %}
        {% assign first_character_in_key = p.first | truncate: 1, '' %}
        {% unless p.last == blank or first_character_in_key == '_' %}
          {{ p.first }}:
          {% if p.last contains '/uploads/' %}
            <a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
          {% else %}
            {{ p.last }}
          {% endif %}
          <br>
        {% endunless %}
      {% endfor %}
    {% endif %}

     

  5. Click Save.

This code checks each line item to see if it has any line item properties, and displays them if they exist.

 

 

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 Templates directory, 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.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 Templates directory, 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.liquid that has an name value of updates[].
  7. Click Save.

 

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:

    {{ line.title }}

    Replace it with:

    {{ line.title }}{% for p in line.properties %}{% unless p.last == blank %} - {{ p.first }}: {{ p.last }}{% endunless %}{% endfor %}

     

  4. Click Save.

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

 

Hide line item properties (optional)

 

 

Line item properties that you have built into your customizable product templates are visible on your product pages and, if you have customized your cart code, on your cart page as well. Line item properties are also visible on the checkout page. There might be times when you do not want a line item property to be visible to the customer, for example, if you want to attach some internal information (such as a bundle ID or tracking number) to a product.

 

If you want a line item property to be hidden on the cart or checkout pages, then you can place an underscore _ at the beginning of its name value. For example, the name value for an internal Bundle ID might look like this:

name="properties[_bundle_id]"

 

If you did not use the code in this tutorial to show line item properties (or customizations) in the cart, then your theme code might not include the code that keeps line item properties with name values beginning with an underscore hidden. To modify your theme code to hide line item properties in the cart, you can add the following lines of code to your cart-template.liquid or cart.liquid file:

{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}

 

The results should look similar to this:

{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
  {% for p in item.properties %}
    {% assign first_character_in_key = p.first | truncate: 1, '' %}
    {% unless p.last == blank or first_character_in_key == '_' %}
      {{ p.first }}:
      {% if p.last contains '/uploads/' %}
        <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
      {% else %}
        {{ p.last }}
      {% endif %}
    {% endunless %}
  {% endfor %}
{% endif %}

 

Showing line item properties at checkout.

 

Line item properties will only be visible to customers during checkout if they are stored as a string. Numbers will be hidden, though they will still be tied to the order and show up in the Admin > Orders screen. For example:

 

  • line_item_prop: "1234" (will be visible on the Order and during checkout)
  • line_item_prop: 1234 (will be visible on the Order and hidden during checkout)

For context, this was introduced as a feature because line item properties were often used to store IDs which were not intended to be customer-facing. So theme developers can hide line item properties during checkout by storing them as an integer or a string with an underscore at the beginning.

TyW | Online Community Manager @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Vrendy
New Member
1 0 4

I think this is a very nice tutorial for what I would like to  do.

However there is no 

type="submit"

in my files:

product-customizable-template.liquid
product.customizable.liquid

Maybe Shopify has changed since this tutorial and I will have to find this somewhere else?

Edit: I found it in the "Snippets" directory, in the "product-info.liquid" file

zephyr74
New Member
1 0 1

Thank you for this tutorial--it was very helpful and solved a problem.  However when I apply these changes, while functionally it works, the newly added fields to not align properly.  Do you have an easy to follow recommendation on how to ensure these line up properly?customization alignment.JPG 

 

As another commenter mentioned, there was no [type="submit"] in my particular theme code.  I did find the button code and added it above that block of code.  It did add the needed fields in the general area, but the already existing Size drop down is throwing the alignment off.

 

Lesaki
New Member
1 0 1

hi everyone !

 

How can i do for get multiples files in my orders ?

 

thank's

ritsybitsy
Tourist
6 0 11

BTW, a very critical missing piece of this is if you want the fields to be required (i.e. have to have data) you have to do one more step not mentioned:

 

See here for details:

https://community.shopify.com/c/Shopify-Design/how-to-make-a-field-required-in-a-form/m-p/494785/hig...

 

nwexpress
New Member
2 0 1

I could not find the "submit" or "button" words in my code. I tried pasting the generated code in a few places but would not work.  Any ideas?

SpokenWood
New Member
1 0 2

That appears to be old code, try searching for this instead:

 

<button type="submit" name="add" id="AddToCart"

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

type="submit" may not live in the product template directly. It often lives within one of the snippet files that the product template is using.

  • Snippets are included in a template using the Liquid tag render (or include) e.g. {% render ‘snippet name’ %}
  • You can find all snippets in the product template file by searching for "render" or "include". The text within the single quotes after "render" is the name of the snippet file being used.
  • You can locate that file within the snippets folder of your theme.
minniebox
New Member
2 0 1

Can someone update the code as this is not updated to work and the comments are still not working for me.  Thank you! 

minniebox
New Member
2 0 1

Hello, I am using the Debut theme and not finding the "submit" in my code to be able to add customization.  I also want to be clear on what info I am removing when added the new code under Sections.  Thank you!

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

Hi @minniebox it's tough to add a tutorial that works for every theme because every theme is different. I downloaded the most recent version of Debut, and I found the type="submit" in the "sections/product-template.liquid" theme file (within the Sections folder here):

 

 

For context, I can see that the product template is rendering two section files with the following code (within"layouts/product.liquid"):

{% section 'product-template' %}
{% section 'product-recommendations' %}

 

That's why I searched for type="submit" in the "sections/product-template.liquid" theme file 🙂

coollyguy
Tourist
7 0 1

Hello,

 

I made it work on my product page and I can see the "Engraving" Section on my product page however, after receiving the order, I cant see it in my order details so I dont know where does this section locate to when customers fill it in. 

Can anyone help me with that as well ? 

 

P.s. I have done everything with the Carts and updated the necessary codes.

Best,

Abdulkadir

 

anywilldo
Shopify Partner
2 0 0

I am having this same issue.  How can I make the field the same size as the "Size" field in the example picture provided?

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

@coollyguy assuming the engraving option has been added to the product form correctly, and engraving information is provided before adding the item to the cart, the line item properties will show up in the Order screen (in the Admin > Orders section) under each item that has been "engraved" 🙂

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

@anywilldo the form inputs that you add to the product template are styled with CSS classes. You'll need to add the right class from your existing theme to the new inputs if you want them styled the same. Every theme is different, so I can't provide a blanket answer here, but you can see what classes and styles are being used within your existing product template, or within your browser's developer tools. Here's a beginner's guide for web developers on changing the webpage with CSS where you can inspect the class of the existing form elements.

 

If that's a little too advanced, I'd suggest reaching out to a Shopify Expert who can ensure the line item properties are properly coded, stored on each order and styled with the rest of your theme 🙂

anywilldo
Shopify Partner
2 0 0

THANK YOU @stratify ! I was able to accomplish what I need with the following butttt I don't understand why I have to have the product-form__item class at the div level and the product-form__input at the object level (select and input).  Is there a cleaner way to do this?  I'm using the Debut 16.4.0 theme

 

<div class="product-form__controls-group">
<div class="selector-wrapper product-form__item">
<label for="options"</label>
<select id="options" name="properties[Options]" required class="required product-form__input">
<option value="Option1">Option 1</option>
<option value="Option2">Option 2</option>
</select>
</div>
<div class="selector-wrapper product-form__item">
<label for="line1"></label>
<input id="line1" type="text" name="properties[Line 1]" maxlength="11" class="product-form__input required" required placeholder="Line 1">
</div>
<div class="selector-wrapper product-form__item">
<label for="line2"></label>
<input id="line2" type="text" name="properties[Line 2]" maxlength="11" class="product-form__input" placeholder="Line 2 (optional)">
</div>
</div>

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

I'm happy to help! Every theme is different and therefore has a specific structure that should be followed. The reason you're seeing specific elements within elements is because most Shopify themes follow the BEM (Block, Element, Modifier) naming convention, which is very helpful for scaffolding reusable theme files and elements. You can always add your own CSS styles to whatever elements you'd like! But it's best to follow the existing CSS/HTML structure, to avoid styles overlapping and causing some unexpected, hair-pulling frustration...

andrew_threlfal
New Member
2 0 0

Not really a CSS question, however having successfully added the file upload functionality to a specific product template, it now then blocks out the variant options once a file is selected to upload. Not sure what/why this is triggered. I have moved the upload file option lower down the page to hopefully get user to make selections, however it is frustrating that once a file is uploaded, the variant options are then not available to be altered. https://www.catfishdesigns.com.au/products/greatnessheatherteels