WooCommerce Rest-Api for getting variable product missing attributes

[ad_1]

After each order I want to extract using rest api the orders info including all info about the order products.

I call the rest api for the order id and then the rest api for each productid or variation_id.

https://SHOPURL.com/wp-json/wc/v3/products/1234?consumer_key=YYYY&consumer_secret=YYYY

I get in result json with all the details about the product with id 1234, including all of it’s attributes.
Assuming there are attributes A and B, while for the product A defined with the optional value (a1), and B with two values (b1 and b2), I get the following in the Json – as expected:

"attributes": [
{
"id": 9,
"name": "A",
"slug": "A",
"position": 0,
"visible": true,
"variation": false,
"options": [
"a1"
]
},
{
"id": 10,
"name": "B",
"slug": "pa_hs_code",
"position": 1,
"visible": true,
"variation": false,
"options": [
"B1",
"B2",
]
}
],

However, if the product ID is variation_id of a variable product with the same attribute A (a1) and B (b1,b2), while attribute B is defined to be the attribute for variation with 2 variation b1 and b2, I do NOT get attribute A in the Json, only the variation attribute with the selected value. Attribute A is not there!

    "attributes": [
{
"id": 15,
"name": "B",
"slug": "B",
"option": "b1"
}
],

I would expect to haver at the variation_id all attributes of the product including the variation attributes. Is it a bug or should I also call the rest api of the product_id (the father of the variation_id) to get the full list of attributes.

Please help.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer