Giving a product a required 'text field' before adding to basket

Giving a product a required 'text field' before adding to basket

ccanning
Excursionist
32 0 10

Hello everyone, 

 

Hope someone can help. 

 

I have a single product, with no variants. I would like to embed a text field to that product, that's mandatory for the user before they add to basket, that they have to provide us with some information. 

 

Is there a way I can do this? I have drafted a render which I hope explains better what I am looking for. 

 

textfieldonorder.jpg

Replies 3 (3)

NomtechSolution
Astronaut
1245 112 151

To add a mandatory text field to a single product in your Shopify store, you'll need to make some modifications to the product template code. Here's a general approach to achieve this:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find your active theme and click on the "Actions" button, then select "Edit Code."
  3. In the left-hand sidebar, locate and click on the "Sections" folder to expand it.
  4. Look for a file named "product-template.liquid" and click on it to open the file in the code editor.

Note: The file name may vary slightly depending on your theme.

  1. Scroll through the code to find the section where you want to add the mandatory text field. This could be in the "Product Form" section or a similar section where the "Add to Cart" button is located.

  2. Within that section, add HTML code for the text field. You can use an HTML <input> tag with the required attribute to make the field mandatory. For example:

 

<input type="text" name="custom_field" required placeholder="Enter your information">

 

  1. Customize the name attribute and the placeholder text to suit your specific requirements.

  2. Save the changes to the "product-template.liquid" file.

  3. Preview your website and navigate to the single product page to see the updated text field. The field should now be mandatory, and customers will need to provide the required information before they can add the product to their cart.

ccanning
Excursionist
32 0 10

Many thanks for this quick response. 

 

These are the closest options I have under the 'Sections' folder. There's:
1. main-product.liquid

2. product-recommendations.liquid

 

Screenshot 2023-05-11 at 12.17.54.png

 

The theme I am using is Dawn, which is a default Shopify theme. 

ccanning
Excursionist
32 0 10

Hi NomtechSolution, 

 

Did you see me previous reply? 🙂