Skip to Content
Menu
This question has been flagged

Hello everyone, I am using Odoo 9 and I have been trying to autopopulate the "Subject" field of the website's contact form.

So far, each product of the shop has an "Add to cart" button, and I have added a "Contact us" button as well. When the user clicks on the "Contact us" button, the user is sent to the Contact Form. In this scenario, I wish to autopopulate the Subject field of the contact form with the product's name that the customer was checking out before clicking on the contact button.For example, if the user is checking out the product named "Computer" and clicks on the corresponding Contact us" button, the subject field should be autopopulated with "Computer".

The nuance to this is that if a customer enters the website for the first time and goes directly to the Contact Form, the Subject field should be empty, since he is not interested in a specific product.


So far I have tried the following code on the "Product" xml template

<a t-att-href="/page/contactus?name=#{product.name}" class="btn btn-primary btn-lg mt8 js_check_product a-submit"> <font style="font-size: 18px;">Contact us</font> </a>

But this instead of populating the form with the product's name, it populates the form with the word "product.name". Does anyone have any idea how to solve this?

Avatar
Discard
Best Answer

You need to extends the Contact Form controller to pass the product object record to the template rendering, also that controller need to receive the product id to be able to retrieve their name or if you like you could pass the name directly for the Contact Us link

Avatar
Discard
Related Posts Replies Views Activity
3
Nov 18
2748
0
Aug 24
218
1
Jul 24
2508
2
Mar 15
4839
2
Mar 15
8167