I'm building a site where WooCommerce Variable products (with Products Variations) are inserted programmatically. I have followed this tutorial successfully:
Insert WooCommerce Products & Variations Programmatically
I need just something that is missing:
How to set variations default attributes values for a variable product?
Is it possible?
1). You will need to insert in your
json
data for each variable product this piece of array like:Or
This array is made with the attribute short slug (without '
pa_
') and the default term name values.2). Then the dedicated function:
3). You will need to trigger this function adding one line at the end:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and works.