Set product tag IDs when creating a product via WooCommerce rest api

Viewed 687

The WooCommerce docs do not provide specific instruction on how the product tags should be set when creating a product.

This is the create product instruction: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

$data = [
    'name' => 'Premium Quality',
    'categories' => [
        [
            'id' => 9
        ],
        [
            'id' => 14
        ]
    ],
];

print_r($woocommerce->post('products', $data));

As a test, I've tried to manually set 2 specific tags to the post which is about to be created. The IDs do already exist I've checked. The post gets created but with no tags set.

I've tried as follows:

$data = [
  'name' => 'Premium Quality',
  'categories' => [
    [
        'id' => 9
    ],
    [
        'id' => 14
    ]
  ],
  'tags' => [
    [
        'id' => 129
    ],
    [
        'id' => 132
    ]
  ],
];
0 Answers
Related