Contact form from product page with url or product id

Shopify Partner
1 0 0

Hello guys, I'm trying to add a form to my product.liquid template because I need a form on every product page but I need that form to include the page url or product id or product title, anything that allows me to recognize where was the form sent from. I have the html form code which I found on the forum at the following URL: 

https://ecommerce.shopify.com/c/ecommerce-design/t/contact-form-from-product-page-with-url-or-produc...

However when I add the code from the above URL. I get the following error:

This file contains the following errors:

  • Line 248 — Liquid syntax error: in 'form' - Valid syntax: form 'type'[, object]
0 Likes

Try one more time:
1. Copy a contact form from page.contact.liquid template
2. Past this form to your product.liquid
3. Add hiden input to page id / url value, like this:
<label class='hide' for="ContactFormProduct">Product id</label>
<input class='hide' type="text" id="ContactFormProduct" name="contact[Product-id]" placeholder="{{ product.id }}">

*or use {{ product.url }} or {{ product.title }}. You can also use them together "{{ product.title }} - {{ product.id }}" ,add to the input placeholder.

Here you can find how to add a field to form: https://help.shopify.com/themes/customization/forms/add-fields-to-your-contact-form

Here you can find a Product variable: https://help.shopify.com/themes/liquid/objects/product#product-id

Hope it helps!
Best,
Arthur

Shopify subject matter expert | Founder at GenovaWebArt | Full-services shopify agency | info@genovawebart.com
0 Likes
Highlighted

In you need to change:
<input class='hide' type="text" id="ContactFormProduct" name="contact[Product-id]" placeholder="{{ product.id }}">

to:
<input class='hide' type="text" id="ContactFormProduct" name="contact[Product-id]" value="{{ product.id }}">

 

:)

Quality e-commerce solutions since 2010.
0 Likes