After Display a form when the selected variation is out of stock in WooCommerce answer to my previous answer, I can display a form made with Contact Form 7 plugin, on the "Out of Stock" products of my WooCommerce store. It works for simple and variable products (product variations).
Now I would like to pass some product data to this enquiry contact form like in this answer:
Pass the chosen product variations data into Contact Form 7 enquiry form.
I would like to pass the product name (and the variation attribute "Color" value, which is "Renk" in my native language). I tried my self in all possible ways, but without any success.
Any help will be appreciated.
2
Answers
As Contact Form 7 allows hidden input field, you will set a hidden input field in your form for the product data (after the submit button) like:
Then You will add it to the mail using for example:
Now jQuery will copy the product name (and the attribute Color value) to this hidden field. Replace your all existing related code with the following:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Note: The code works for simple products and for variable products (product variations).
Related:
This resource from cf7 docs helped me.
To pass product name into cf7 form: