Search code examples
.netwoocommerce-rest-api

Add attributes in Product using Woocommrece API


When I create the attribute for the product from the API Woocommerce , the attribute does not appear on the page of my site WordPress, so I have to refresh the publication for the product manually please any help?

enter image description here

enter image description here


Solution

    1. First If you have attributes already created in attributes section Woocommerce.You can update by this PUT:- http:/example.com/wp-json/wc/v3/products/123 BODY:

      { "attributes": [ { "id": 4, //Example: color's ID "options": "white" } ] }

    2. If attributes are not present in the attributes section, please create the attributes and assign to the products.You can create attributes in this way. POST:- /wp-json/wc/v3/products/attributes

      BODY:

      { "name": "Color", "slug": "pa_color", "type": "select", "order_by": "menu_order", "has_archives": true }