jesse1981
8/12/2018 - 4:23 AM

WooCommerce: Add Product

<?php
$data = [
  'name'              => 'My Product',
  'type'              => 'simple',
  'description'       => 'A full description',
  'short_description' => 'A brief description',
  'categories'        => [['id' => 1]],
  'regular_price'     => '1.50',
  'sale_price'        => '1.00',
  'images' => [
    [
      'src' => 'https://i.chzbgr.com/full/9200726016/hEA6D171D/',
      'position' => 0
    ]
  ],
  'attributes'        => [
    [
      'id'        =>  0,
      'name'      => 'catalogue_id',
      'options'   => ["_cid_1234_"],
      'position'  => 2,
      'variation' => false,
      'visible'   => false
    ],
    [
      //...
    ]
  ]
];
$res = $wooObj->addProduct($data);
?>