I just started to work with WordPress and WooCommerce plugin and came across the issue: On Frontend I want to render an item card with a list of items variants and by clicking on the variant to do AJAX request to fetch price, photos etc for certain variant. But WooCom API for request /products/ returns:

...,
    "attributes": [
        {
            "id": 1,
            "name": "Color",
            "position": 0,
            "visible": true,
            "variation": true,
            "options": [
                "Deep Blue",
                "red"
            ]
        }
    ],
    "default_attributes": [
        {
            "id": 1,
            "name": "Color",
            "option": "deep-blue"
        }
    ],
    "variations": [
        20,
        19
    ],

which is odd and useless, because "variations" field is just list of ids and "attributes" -> "options" just array of strings and how I can now map it together? I would expect something like this:

    "attributes": [
        {
            "id": 1,
            "name": "Color",
            ...
            "options": [
                [value => "Deep Blue", variantId => 30],
                [value => "Red", variantId => 29],
            ]
        }
    ],

Does anybody know if there are any ways to handle it?

0 Answers