• Resolved goranpro

    (@goranpro)


    Hi,

    Is there a way to use the REST API in a way that I could assign new tags to a product without needing to first collect all existing tags into an array?

    Im asking because i tried to do the code bellow and all existing product tags have been removed and the product was left only with the one that I added with the code:

    $tags[] = array(‘id’ => 13);

    $data = [
    ‘tags’ => $tags,
    ];

    $woocommerce->put(‘products/’ . $productId, $data);

Viewing 1 replies (of 1 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @goranpro Unfortunately, no. The present tags will need to be queried if you are looking to append new ones and not overwrite the existing ones.

    This chunk is called when saving, which calls this chunk, which just overwrites what is existing.

Viewing 1 replies (of 1 total)
  • The topic ‘REST API – assign new tags’ is closed to new replies.