WooCommerce product variations added through API not showing in backend
-
We are trying to add a variant to a variable product using v3 API.
First we add attributes to the system: Culoare – Rosu, Gri, Negru; Marime – 32, 34, 36.
This is ok we see effect in the backend.Then we add variable product with the following JSON, containing all attribues combinations available.
{
“regular_price”:”10″,
“sku”:”2″,
“attributes”:[
{
“visible”:”true”,
“options”:[
“Rosu”,
“Negru”,
“Gri”
],
“variation”:”true”,
“id”:2
},
{
“visible”:”true”,
“options”:[
“32”,
“34”
],
“variation”:”true”,
“id”:3
}
],
“status”:”draft”,
“description”:””,
“sale_price”:”10″,
“IDSMARTCASH”:2,
“manage_stock”:”true”,
“type”:”variable”,
“tax_class”:”tva-b-9″,
“name”:”Pitza”
}
The result is successful (we receive id for product 2092 and we see the product in the backend).
Then we call POST method https://staging28.market.smartcash.store/wp-json/wc/v3/products/2092/variations
with the following JSON
{
“regular_price”:”10″,
“sku”:”7″,
“attributes”:[
{
“id”:2,
“option”:”Gri”,
“name”:”Culoare”
},
{
“id”:3,
“option”:”32″,
“name”:”Marime”
}
],
“status”:”draft”,
“description”:””,
“sale_price”:”10″,
“IDSMARTCASH”:7,
“manage_stock”:”true”,
“tax_class”:”tva-b-9″
}
The result have no errors and the variant is added with the id = 2121.However we cannot see the variant in the list of variations in the backend.
We noticed that for manually added variations the variable product hold in the array “variations” all the id’s of the “childs”
ex:
“variations”: [ 2001, 2002, 2003 ], But on our case, when adding variations through API (v3) this array is always empty.What are we missing?
Everything seems to be ok but WooCommerce does not update the “variations” node and consequently the backend.`
- The topic ‘WooCommerce product variations added through API not showing in backend’ is closed to new replies.