Skip to content

Instantly share code, notes, and snippets.

View zverush's full-sized avatar
🚀
WordPress

Aleynikov Sergey zverush

🚀
WordPress
View GitHub Profile
@zverush
zverush / import-variation.php
Created December 21, 2015 16:50 — forked from galalaly/import-variation.php
Create WooCommerce variations with PHP
<?php
// In a class constructor
$this->size_tax = wc_attribute_taxonomy_name( 'Size' );
$this->color_tax = wc_attribute_taxonomy_name( 'Color' );
// Insert the main product first
// It will be used as a parent for other variations (think of it as a container)
$product_id = wp_insert_post( array(