Created Simple product programatically
-
Hello,
I am trying to create simple product programmatically and when i going to apply below code then i got some warning. see this screenshot( https://prnt.sc/N3WcJaZr_DO- ). even after those warning product added more than one also.
My code:
$product = new WC_Product_Simple();
$product->set_name(“Apple Watch”);
$product->set_slug(“apple-watch”);$product->set_short_description(“Excellent Product”);
$product->set_regular_price(2500);
$product->set_sale_price(500);$product->set_image_id(14);
$product->set_category_ids(array(20));$product->save();
By the way, I am using WordPress version: 6.2.2 and WooCommerce version is 7.8.2
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Created Simple product programatically’ is closed to new replies.