Skip to content

Instantly share code, notes, and snippets.

View madebycaliper's full-sized avatar

Eli Silverman madebycaliper

View GitHub Profile
@the-nerdery-dot-info
the-nerdery-dot-info / programmatically_create_variable.php
Last active January 13, 2021 21:55
programmatically create woocommerce product in php
//Hi, i created a function for adding variable products based on your code. I share it here in case anyone needs it:
//The first parameter is the title of the product, $cats is the products category id which has to be an array and must be created previously, $variations is an array which contains the variations with prices, descriptions, discount, and $variations_key is the key of the parent attribute which has to be created previously on teh attributes page.
//I´m creating a ticket´s selling store and I´m using 2 globals: $logger and $vgh from my framework, please ignore them.
<?
function create_variable_woo_product($title, $cats = array(), $variations, $variations_key) {
global $wpdb, $logger, $vgh;