Product pages - Get customization information for products

TyW
Community Manager
451 63 1206

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 279 (279)

TyW
Community Manager
451 63 1206

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
451 63 1206

 

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
Visitor
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

SpokenWood
Visitor
1 0 2

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

 

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

fodell
Tourist
4 0 1

hi everyone !

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

fodell
Tourist
4 0 1

How can i do for get multiples files in my orders

 

 

 

 

 

 

snaptube      vidmate

DrTrujillo
Tourist
6 0 1
I have this exact issue, I managed to follow this tutorial and add forms to the Debut theme but the the I am using now (Debutify) seems to have that coding in the Snippets section as well, how can we go around this?
huanineupane
Tourist
8 0 6

I followed the tutorial and failed to find the "submit" section too initially. Later I found this was because I did not paste correct code into the new "product-customizable-template".

Which means, to correctly follow this:

 

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.

 

-Delete all the code from "product-customizable-template" (in the Section folder).

-Find the "product-template.liquid" from the Section Folder. Note: this file from Section folder NOT the Template folder we created earlier. 

-Find the "submit" keyword, press "Command+F" to find it. 

 

I hope that helps. 

AndrewCottage
Visitor
1 0 0

I use motion and found it in snippets too. But now it applies the custom option for all products. How do I adjust products for those that show show custom options vs. those that should not?

gisselleyes
Tourist
3 0 1

Hi there!

I am also not able to find the type="submit". Are you able to explain how you did it? I would really appreciate it, thank you!

Gariep
Excursionist
29 0 9

i did not had this either, you can try to add it elsewhere in your code, it will change the position of the input box.   

zephyr74
Visitor
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
Visitor
1 0 1

hi everyone !

 

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

 

thank's

sdjg
Visitor
2 0 0

Did you ever work out how to do this?

Tracy14
Tourist
5 0 0
Hi,

Yes it's a bit of a pain but you have to create a new Section product code
and a Template directing it to the Section for every set of personalisation
requirements you have.

Then on the product page select the theme template you require for the
products.

I am using Theme Debut

Example of Section code I am using from line 179:


Line 1 Name

type="text" name="properties[Line 1 Message]">


Line 2 Message

type="text" name="properties[Line 2 Message]">


Line 3 Pencil 1

type="text" name="properties[Line 3 Message]">


Line 4 Pencil 2

type="text" name="properties[Line 4 Message]">


Then I link it to the temple using the same name so for example the above
would be product -n12-m50-p20-p20

I would then edit line5 of the Template from {% section 'product-template'
%} to say {% section 'product-n12-m50-p20-p20' %}

Please remember I am new to this. It seems to be working for me but that is
not to say it is the correct way to do it.

If you come across a better way please let me know.

Good luck!

nwexpress
Visitor
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?

stratify
Shopify Staff (Retired)
20 2 13

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.

To learn more visit the Shopify Help Center or the Community Blog.

minniebox
Visitor
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! 

DrTrujillo
Tourist
6 0 1
Hmm... So I guess the fix to this should be creating another product-template.liquid on the Snippets section named product-customizable-template.liquid, then copying and pasting the code from the original template to the customizable one and changing the rendering name to the new template.liquid?
mraculus
Tourist
5 0 1

I am using debuity theme and having problems implementing this feature. Can anyone shed some light on this?

mraculus
Tourist
5 0 1

I am using debutify theme and haveing problems implementing this. Is there a tutorial specific for debutify theme?

lukam
Visitor
2 0 2

I have been able to get this work however one issue i cant solve is getting the custom text box to show on the home page when I add the product as a featured product. Then the custom text box doesn't show even though it does show on the actual product page. Any suggestions?

JLSGLG
Tourist
8 0 4

How did you get it to work? I can't find the right place to paste the code.

mraculus
Tourist
5 0 1

Hi, were you able to figure this out? I have the same problem

huanineupane
Tourist
8 0 6

Hi, 

Thanks for the tutorial, I was able to add a customised input box. Now  I have a problem with using the input. I tried doing {{item.properties}} to access that information. But it does not have anything. Can you please advice?

 

Saeadamas
New Member
6 0 0

Hello, I tried to follow the tutorial

 

But it seems like my custom field isn't mandatory as I want it to be, because I can add it to the card without filling it

and something else is I cannot see the custom field text line in the "Cart" section

 

Could someone please help me ?

Saeadamas
New Member
6 0 0

This is where I put my lines

 

<div class="product__content-main">
<div class="product__description rte" itemprop="description" class="rte">
{{ product.description }}
</div>

<div class="product__form-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div class="product__form-wrapper">
<div class="product__form-item">
<label for="votre-prenom">Votre prénom</label>
<input required class="required" id="votre-prenom" type="text" name="properties[Votre prénom]">
</div>
<meta itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}">
<meta itemprop="priceCurrency" content="{{ cart.currency.iso_code }}">
<link itemprop="availability" href="http://schema.org/{% if current_variant.available %}InStock{% else %}OutOfStock{% endif %}">

PaulNewton
Shopify Partner
6274 572 1315

@Saeadamas If I have free time i'll take a glance what is your theme,store, and storefront password if applicable.

 

Have you made sure the elements you've added are inside either an html <form> or liquid {% form %}?

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Saeadamas
New Member
6 0 0

@PaulNewton wrote:

@Saeadamas If I have free time i'll take a glance what is your theme,store, and storefront password if applicable.

 

Have you made sure the elements you've added are inside either an html <form> or liquid {% form %}?


Thank you so muchj Paul, me theme is "Narrative" and my password is "reffah"

 

I do think so, I didn't find a <form> So I inserted the text near " Product Form & Description"

Saeadamas
New Member
6 0 0

That's the product I have a problem with

 

https://saeadamas.com/products/collier-en-diamant-incruste-avec-nom-arabe-personnalise

 

The text Custom Field isn't mandatory, and I cannot see the text I filled in the Cart

PaulNewton
Shopify Partner
6274 572 1315

Problem - form <input> elements outside of form

 

Solution #1

In your product template find the relevant <form> html tag or the liquid {% form %} tag , may vary by theme or template.

Before the relevant closing </form> html tag,  or {%endform%} liquid-tag,   cut and paste your <input> , and any surrounding or associated elements such as <labels> from the improper location into the form tags.

 

Solution #2  Advanced 

If you are only supporting HTML-5 compliant browsers and need the inputs to not have a <form> ancestor (be inside a html form) consider using the html5 input attribute "form"

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefform

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form

Note:  Internet Explorer has no support for this attribute, check for others browsers support https://caniuse.com/#feat=form-attribute 

 

Example - if the forms id is "product_form_12345678901234" then to associate an input to a form using the value of that forms ID attribute:

<input form="product_form_4613396496456" properties=[Your first name] />
<input required="" form="product_form_4613396496456" class="required" id="votre-prenom" type="text" name="properties[Votre prénom]"> <form id="product_form_4613396496456"> ..... </form>

Liquid - In shopify themes the ID is commonly initially generated in liquid with 'product_form_{{product.id }}', or {{product.selected_or_first_available_variant}}

Javascript - The form id or input attributes may also be update with javascript in some themes.

 

Note: input controls not in a form can be hard to pinpoint as they pass html validators like https://validator.w3.org/ 

the following CSS snippet can be use to quickly find such form controls:

/* outline form controls in red */
input, select, textarea { outline: 6px dotted red !important; }
/* not outline form controls that are descendents of a <form> element */
form input, form select, form textarea { outline: 6px dotted green !important;}

 

 

@Saeadamas  This code 

<input required="" class="required" id="votre-prenom" type="text" name="properties[Votre prénom]">

Is not inside the rendered form , it is outside of it so it does not get submitted with the form when the user clicks add to cart

<form method="post" action="/cart/add" id="product_form_4613396496456" accept-charset="UTF-8" class="product-form" enctype="multipart/form-data"><input type="hidden" name="form_type" value="product">

 

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Saeadamas
New Member
6 0 0

Thank you so much for the complete answer Paul, being extremely new to coding I only understood half of what you said.

Do you think you can tell me, if my line codes are outside the "form"

Thank you again 🙂

 

{%- assign current_variant = product.selected_or_first_available_variant -%}
{%- assign current_variant_sale = false -%}
{% if current_variant.compare_at_price > current_variant.price %}
{%- assign current_variant_sale = true -%}
{% endif %}
{% assign featured_media = current_variant.featured_media | default: product.featured_media %}

<div class="product-template" data-section-id="{{ section.id }}" data-section-type="product-template" data-variant-id="{{ current_variant.id }}" itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="{{ product.title }}">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
<meta itemprop="image" content="{{ featured_media | img_url: 'grande' }}">

{% comment %}
------------------------------------------------------------------------------
Product Featured Media
------------------------------------------------------------------------------
{% endcomment %}
<div class="page-width page-width--no-gutter">
{% assign variant_media_ids = '' %}

{%- unless product.has_only_default_variant -%}

{% for variant in product.variants %}
{% assign variant_media = variant.featured_media %}


{%- if variant_media -%}

{%- if variant_media_ids contains variant_media.id -%}
{% continue %}
{%- endif -%}

{% assign variant_media_ids = variant_media_ids | append: variant_media.id | append: ' ' %}
{% assign featured = false %}
{%- if featured_media == variant_media -%}
{% assign featured = true %}
{%- endif -%}

{% include 'product-preview-image' with media: variant_media, featured_media: featured, gallery_type: 'media', data_image: 'data-variant-media-image' %}
{%- endif -%}

{% endfor %}
{%- endunless -%}

{% unless featured_media and variant_media_ids contains featured_media.id %}
{% include 'product-preview-image' with media: featured_media, featured_media: true, gallery_type: 'media', data_image: 'data-variant-media-image' %}
{%- endunless -%}

{% include 'shopify-xr-button' %}
</div>

{% comment %}
------------------------------------------------------------------------------
Product Form & Description
------------------------------------------------------------------------------
{% endcomment %}
<div class="product__content page-width">
<div class="grid">
<div class="grid__item medium-up--push-one-twelfth medium-up--ten-twelfths">
<div class="product__content-header">

{% if section.settings.show_vendor %}
<span class="product__vendor text-small text-center" itemprop="brand">{{ product.vendor }}</span>
{% endif %}

<h1 class="product__title h2 text-center" itemprop="name">{{ product.title }}</h1>
<p class="product__price text-center{% if current_variant_sale %} product__price--sale{% endif %}" data-product-price aria-live="polite">

<span class="product__sale-price-label visually-hidden">{{ 'products.product.sale_price' | t }}</span>
<span class="product__regular-price-label visually-hidden">{{ 'products.product.price' | t }}</span>
<span class="product__current-price" data-regular-price>{{ current_variant.price | money }}</span>

<span class="product__compare-price-label visually-hidden">{{ 'products.product.regular_price' | t }}</span>
<s class="product__compare-price" data-compare-price>{{ current_variant.compare_at_price | money }}</s>

{% include 'product-unit-price', variant: current_variant %}
</p>

{%- if shop.taxes_included or shop.shipping_policy.body != blank -%}
<div class="product__policies rte">
{%- if shop.taxes_included -%}
{{ 'products.product.include_taxes' | t }}
{%- endif -%}
{%- if shop.shipping_policy.body != blank -%}
{{ 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url }}
{%- endif -%}
</div>
{%- endif -%}

</div>

<div class="product__content-main">
<div class="product__description rte" itemprop="description" class="rte">
{{ product.description }}
</div>

<div class="product__form-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div class="product__form-wrapper">
<div class="product__form-item">
<label for="votre-prenom">Votre prénom</label>
<input required class="required" id="votre-prenom" type="text" name="properties[Votre prénom]">
</div>
<meta itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}">
<meta itemprop="priceCurrency" content="{{ cart.currency.iso_code }}">
<link itemprop="availability" href="http://schema.org/{% if current_variant.available %}InStock{% else %}OutOfStock{% endif %}">

{% include 'product-form' %}
{% if section.settings.show_share_buttons %}
{% if settings.share_facebook or settings.share_twitter or settings.share_pinterest %}
<div class="product__share-wrapper small--hide">
<div class="product__share">
{% include 'social-sharing', type: "product", links: 'bottom' share_title: product.title, share_permalink: product.url, share_image: featured_media %}
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>

</div>
</div>
</div>
</div>

{% comment %}
------------------------------------------------------------------------------
Product Share Buttons
------------------------------------------------------------------------------
{% endcomment %}
{% if section.settings.show_share_buttons %}
{% if settings.share_facebook or settings.share_twitter or settings.share_pinterest %}
<div class="product__share-wrapper product__share-wrapper--mobile medium-up--hide">
<div class="product__share">
{% include 'social-sharing', type: 'mobile', share_title: product.title, share_permalink: product.url, share_image: featured_media %}
</div>
</div>
{% endif %}
{% endif %}


{% comment %}
------------------------------------------------------------------------------
Product Media Gallery
------------------------------------------------------------------------------
{% endcomment %}
{%- if product.media.size > 1 -%}

{% comment %}
If we are hiding variant media which are displayed at the top of the
page, then find total number media not set as a variant media or as the
featured media.

We need the total number of media to be displayed so that we know what
arrangement the media need to be positioned in, i.e. rows of 3 or 2
media.
{% endcomment %}

{%- if section.settings.hide_variant_media -%}
{% assign variant_media_ids_array = variant_media_ids | split: ' ' %}
{% assign total_media = product.media.size | minus: variant_media_ids_array.size %}
{%- else -%}
{% assign total_media = product.media.size %}
{%- endif -%}

{% comment %}
Insert images into rows of 3 and/or 2 depending on the total number of
images.
{% endcomment %}
{% assign total_modulus = total_media | modulo: 3 %}

{% if total_media == 1 %}<div class="page-width">{% endif %}

<div class="product__submedia-list product__submedia-list--r{{ total_modulus }}{% if total_media == 1 %} product__submedia-list--single{% endif %}">

{% for media in product.media %}

{% unless variant_media_ids contains media.id and section.settings.hide_variant_media %}
{% capture data_image %}
data-parent-fit="cover"
{% endcapture %}

{% include 'product-preview-image' with media, featured_media: false, gallery_type: 'submedia', data_image: data_image %}

{% endunless %}
{% endfor %}
</div>

{% if total_media == 1 %}</div>{% endif %}
{% endif %}

{% comment %}
------------------------------------------------------------------------------
Product Slideshow
------------------------------------------------------------------------------
{% endcomment %}
{% unless product.media.size == 0 %}
<div class="product-slideshow{% if product.media.size == 1 %} product-slideshow--single{% endif %} critical-hide" data-product-slideshow data-media-group aria-hidden="true">
<button class="product-slideshow__close btn btn--clear btn--square" tabindex="-1" data-product-slideshow-close>{% include 'icon-close' %}</button>

<div class="product-slideshow__content">
<div class="product-slideshow__slide-list slider" data-product-slider>
{% for media in product.media %}
{%- capture product_media_wrapper_class -%}
product-slideshow__slide slider__slide{%- if forloop.first %} slider__slide--active {%- endif -%}
{%- endcapture -%}

{% include 'media' with media,
section_type: 'slideshow',
parent_fit: 'contain',
featured_media: true,
data_image: 'data-product-slideshow-image',
product_media_wrapper_class: product_media_wrapper_class,
product_media_wrapper_data: 'data-product-slideshow-slide',
image_class: 'fade-in'
%}
{% endfor %}
</div>

{% include 'shopify-xr-button' %}

{% unless product.media.size == 1 %}
<div class="product-slideshow__controls">
<button class="product-slideshow__arrow product-slideshow__arrow--previous btn btn--secondary btn--square"
tabindex="-1"
data-product-slideshow-previous>

{% include 'icon-arrow-left' %}
<span class="visually-hidden">{{ 'general.pagination.previous' | t }}</span>
</button>

<button class="product-slideshow__arrow product-slideshow__arrow--next btn btn--secondary btn--square"
tabindex="-1"
data-product-slideshow-next>

{% include 'icon-arrow-right' %}
<span class="visually-hidden">{{ 'general.pagination.next' | t }}</span>
</button>

<div class="product-slideshow__slide-select-list">
{% for media in product.media %}
<button class="product-slideshow__slide-select {% if forloop.first %} product-slideshow__slide-select--active{% endif %}" tabindex="-1" data-product-slideshow-select="{{ forloop.index0 }}">
<span class="visually-hidden">{{ 'sections.product_template.slide' | t: number: forloop.index }}</span>
</button>
{% endfor %}
</div>
</div>
{% endunless %}
</div>
</div>
{% endunless %}

{% comment %}
------------------------------------------------------------------------------
Product Data
------------------------------------------------------------------------------
{% endcomment %}
<script type="application/json" data-product-json>
{{ product | json }}
</script>

<script type="application/json" data-model-json="{{ section.id }}">
{{ product.media | where: 'media_type', 'model' | json }}
</script>
</div>

PaulNewton
Shopify Partner
6274 572 1315

When pasting code there is an "insert code" formatting button, please avoid pasting very big files, and files in their entirety that belong to a theme.

The keyword here is form if you have a similar issue be sure to look in all related included snippets|files inside the product template for the relevant form tags

@Saeadamas 

Fortunately I knew what to look for with ctrl+f so didn't have to read that whole thing 😉

You've been putting the line item properties in the product page template, aka the PDP,  but not in the product form itself which is a snippet: 

 

{% include 'product-form' %}

 

Move your code into that file, using my previous solution steps looking for <form... or {%form.. type tags

 

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Saeadamas
New Member
6 0 0

Oh ok I'm Sorry.

So I did move my Code lines on the right section as you directioned me, but now unfortunately I cannot see the Custom Field on my product page anymore

PaulNewton
Shopify Partner
6274 572 1315

@Saeadamas looked at your site and the code location is unchanged, you may need to reread the directions and find the right location or use the form attribute method.

Goodluck

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


GeraldLee
Tourist
14 0 0

Hi Paul, could you assist on how to have my 3 options to be on the same line? Also, I would like the dropdown box background colour to be #000000 with the words in #FAEBD7.  Thank you in advance!

Screenshots: Untitled.png

Code: 

			<p class="line-item-property__field">
  			<label>Canned Cocktail #1</label><br>
 			<select required class="required" id="canned-cocktail-1" name="properties[Canned Cocktail #1]">
    		<option value="Orh Huey">Orh Huey</option>
    		<option value="Ju Hua">Ju Hua</option>
    		<option value="Espresso Martini">Espresso Martini</option>
    		<option value="Skittles">Skittles</option>
    		<option value="White Sangria">White Sangria</option>
    		<option value="Red Sangria">Red Sangria</option>
  			</select>
			</p>
          <p class="line-item-property__field">
  <label>Canned Cocktail #2</label><br>
  <select required class="required" id="canned-cocktail-2" name="properties[Canned Cocktail #2]">
    <option value="Orh Huey">Orh Huey</option>
    <option value="Ju Hua">Ju Hua</option>
    <option value="Espresso Martini">Espresso Martini</option>
    <option value="Skittles">Skittles</option>
    <option value="White Sangria">White Sangria</option>
    <option value="Red Sangria">Red Sangria</option>
  </select>
</p>
          <p class="line-item-property__field">
  <label>Canned Cocktail #3</label><br>
  <select required class="required" id="canned-cocktail-3" name="properties[Canned Cocktail #3]">
    <option value="Orh Huey">Orh Huey</option>
    <option value="Ju Hua">Ju Hua</option>
    <option value="Espresso Martini">Espresso Martini</option>
    <option value="Skittles">Skittles</option>
    <option value="White Sangria">White Sangria</option>
    <option value="Red Sangria">Red Sangria</option>
  </select>
</p>
PaulNewton
Shopify Partner
6274 572 1315

@GeraldLee that's a design issue separate from the customization you'll want to make a different post in the design forum for extended  structural andlstyling help.

 

.line-item-property__field {
display:block; width: 32%;
color: #FAEBD7; }
.line-item-property__field select option {
background-color: #000000;
}

 

 

 

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


ConsumerProduct
Excursionist
18 0 3

I followed this guide to get customization information for products on my product page, but i'd like to get it working on my home page as well.

https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-produ...

Is there any way to do this? Thank you in advance for your help!

Agreeableagony
Excursionist
17 0 2

Paul,

I am trying to implement this on a sectioned site using the Supply theme, and it has no effect at all.

This is the code I have:

<p class="line-item-property__field" {
display: block;
width: 32%;
}

What am I missing from this?

I also have a list of checkboxes generated by the UI elements generator that looks terrible on the actual page... 
https://www.agreeableagony.com/collections/rope/products/custom-color-mfp-rope?variant=2944678110833...

I am struggling to find the right search terms to just go look up the flags and their implementations. 

AG-Mens-Jewelry
Excursionist
12 1 18

How would you like the dropdowns to look "visually", and also what do you mean about "flags"? Are you only trying to display certain line-property options base on product tags?

policenauts
Shopify Partner
206 10 65

The underscore trick is not working for items added to POS cart - line item properties show in the POS cart as well as the customer receipt which is not acceptable. Is there an equivalent workaround here? 

PaulNewton
Shopify Partner
6274 572 1315

@policenauts wrote:

The underscore trick is not working for items added to POS cart - line item properties show in the POS cart as well as the customer receipt which is not acceptable. Is there an equivalent workaround here? 


Could you try this with double __ underscores on the LIP's , otherwise you may want to try those techniques with cart attributes instead though you'll want to add either the variant id or the line_item key hash

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


sdjg
Visitor
2 0 0

Is it possible to create different forms to apply to different products?

arpanroy
Shopify Partner
1 0 0

I have added all these code and it is working perfectly. But when I added calculator builder for calconic app then it was not showing my customization information in cart & order page. Before adding this app it was working perfectly. How can I solve these issue?

Weng2
Visitor
1 0 1

Hi,

We are using the Warehouse theme, and we want to do customize products for specific products on our website.

But, we can't edit the code because the tutorial is different from ours.

Is there any possibility that you can do the tutorial of the Warehouse theme?

 

Thanks

AnnetteKolbeck
Visitor
2 0 1

We are also using Warehouse, and cannot get further either....

Thank you. 

Chalotte

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)
20 2 13

@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 🙂

To learn more visit the Shopify Help Center or the Community Blog.

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>