August 11, 2019: Improved support for List fields. Updated article with currently applicable fields.
Some complex fields (like Checkbox, Multi Select, List and Single Product fields) do not provide a default value setting. But they do support dynamic population.
This snippet enables the ability to use merge tags as dynamic population parameters, allowing you to specify default values for complex fields.
How do I install this snippet?
Just copy and paste the code into your theme’s functions.php file.
Do I need to customize the snippet to work with my form?
Nope! This one is generic and will work for all forms out of the box. Here is what it will look like once you’ve added a couple merge tags to your dynamic population parameter settings.
Does the data I am populating need to be in a specific format?
Yes! Each field expects its data in a specific format.
|List (Single Column)||
|Single Product (Name)||
|Single Product (Price)||
|Single Product (Qty)||
Let me know how you use this in the wild! Be sure to check out the Dynamic Products via Post Meta article which makes use of this handy snippet.