Woocommerce REST API Update Categories in Product
-
Using the following code I am successfully updating the basic product data (title, description, sku, price etc) but I can’t get the categories to update.
Request: https://mysite/wp-json/wc/v3/products/3517
{ "catalog_visibility": "visible", "categories": [ 343, 347 ], "description": "teste", "dimensions": { "height": "2", "length": "15", "width": "11" }, "featured": false, "id": 3517, "images": [ { "id": 3514 } ], "manage_stock": false, "meta_data": [ { "key": "woosb_ids", "value": "3465/1,3490/1" }, { "key": "woosb_disable_auto_price", "value": "on" } ], "name": "Test", "regular_price": "94.96", "sale_price": "94.96", "short_description": "Teste", "sku": "010051101080", "status": "publish", "stock_quantity": null, "stock_status": null, "type": "woosb", "weight": "0.200" }
As I say, the other fields update as expected. I have confirmed that categories with IDs 343 and 347 definitely exist so I assume I must have a problem with the syntax. As the other fields update the authentication is definitely working. It seems that it only inserts new categories in the product, but never removes the link in the update
I’m using WordPress 6.1.1 with Woocommerce 7.0.0, to update products on the website when they are changed in a separate product management system. is using v3 of the REST API.
- The topic ‘Woocommerce REST API Update Categories in Product’ is closed to new replies.