WooCommerce – Create Products Programatically [closed]

Technically speaking, Woocommerce products are just another WordPress post object with a customized post type (which is product in this case). If you take a look at the create_product function inside class-wc-api-products.php, you’ll see this line:

// Attempts to create the new product
$id = wp_insert_post( $new_product, true );

So the API ends up using wp_insert_post eventually. I guess you can do both but it’s obviously using what WooCommerce API provides to create a WooCommerce product is a better way to go.

Leave a Comment