How can I add a page URL to the Contact Form email in Dawn 3.0.0?

Hi,

I’m using Dawn 3.0.0. theme and use the Contact Form (contact-form.liquid) in both my Contact page and product pages. I would like to add the page URL in the form email sent so I know which product my visitor is inquiring about.

Thanks.

You can add this piece of code just above the submit button of the contact-form.liquid:

{% if product.url %}

{% endif %}

This will add the product URL to the email sent to you, when it is sent from a product page.

use this code

{% assign full_url = request.host | append: request.path %}

add input field in contact form

{% comment %}
Add below code inside the contact form so it will send product url while on product page submit form

{% endcomment %}

{% if template contains ‘product’ %}
{% assign full_url =product.url %}

{% endif %}

try code and let me know if it works

@Sajeel Huhh how your code i think this is a solution which you and me both providing.
You can see there is difference on code yours and mine.

you just wraped my code into template i used full_url variable you used the same. hahahah

@Sajeel

please match this line of code then reply again here

@Niraj_singh how we both can use this same variable full_url? you used and modified the code bit . no problem bro best of luck

@Sajeel this type of variable are universal and every developer practice same.

Thank you - this code works. Would it be possible to adapt your code to include the full product URL as a clickable link in the email sent?

Thank you for all the ideas. I decided to use product.title to include in the form email.