Hi all,
For a project I need to fetch data into a Gravity Form. I created a form on the thank you page and via conditional logic I would like to show fields based on the product that has been bought. How can I fetch the product title inside a field in GF?
To fetch the product title in Gravity Forms, you can use the “Dynamic Population” feature. This allows you to pre-populate a form field with a value from the URL query string, a cookie, or a Gravity Forms merge tag.
Here’s how you can use this feature to populate a form field with the product title:
- In your Gravity Form, add a new “Single Line Text” field where you want the product title to be displayed.
- In the Field Options for the text field, go to the “Dynamic Population” tab.
- In the “Parameter Name” field, enter the parameter you want to use to pass the product title to the form. For example, you might use “product_title” as the parameter name.
- In the “Default Value” field, enter the merge tag that will be used to retrieve the value for the product title. The merge tag for the product title would be “{product_title}”.
- Save your form.
When the form is displayed, it will automatically fetch the value for the product title from the URL query string (or cookie or another source) and populate the text field with that value.
For example, if the URL of the thank-you page is “https://example.com/thank-you?product_title=My+Product
”, the form field will be pre-populated with the value “My Product”.
Hi Faisal,
Thank you for helping. I know the populate option. The only problem is that the url is not showing the product name. Instead it’s showing this: /checkout/order-received/78/?key=wc_order_JeZg43Gaat2
Unfortunately the form field will display {product_title} instead of the real product title. Is there an way to let the url show the name?
How is it possible to fetch the name from the cookies?
I found a way to add the product ID to the url. Based on that I can show the right form fields. Thanks for helping.