How to add product in woocommerce with php code

I want to add products with PHP code like below: $post_information = array( 'post_title' => 'new item shop', 'post_content' => 'this is new item shop', 'post_type' => 'post', 'post_status' => 'publish' ); $post_id = wp_insert_post($post_information); but this code optimize for WooCommerce such as post type and guid and metadata and… Can someone help? Answers: Thank … Read more

Woocommerce – Add a product to cart programmatically via JS or PHP

I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to its cart via some call or function rather than using its own ‘add-to-cart’ buttons. By this I basically mean send Woocommerce a SKU and quantity for example and have the cart update. sendToCart('123456', 55); … Read more