fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Updating color swatches using the API

Fábio Pires

Hello,

I’m using your variation swatches plugin and I’m trying to update the color attribute using the WooCommerce API. I’ve found the “woo_variation_swatches” object on the attribute terms and I see that I can get the color value for each term, using a GET request. But I need to update that color attribute using a POST request. I’m sending this on the POST request to the “/wp-json/wc/v3/products/attributes//terms” endpoint:

{ “name”: “Vermelho”,
“slug”: “pat_421_vermelho”,
“woo_variation_swatches”: {
“attribute_type”: “color”,
“primary_color”: “#ff0042”
}
}

As you can see, I send the correct HEX value for the primary_color. I get a correct response with status 201. But the primary_color value is blank:

{
“id”: 322,
“name”: “Vermelho”,
“slug”: “pat_421_vermelho”,
“description”: “”,
“menu_order”: 0,
“count”: 0,
“woo_variation_swatches”: {
“attribute_type”: “color”,
“primary_color”: “”,
“secondary_color”: “”,
“is_dual_color”: false,
“dual_color_angle”: “-45deg”,
“image_id”: 0,
“image_size”: “”,
“group”: “”,
“group_name”: “”,
“tooltip”: “”,
“tooltip_text”: “”,
“tooltip_image_id”: 0
}
}

How can I update the primary_color value using the API?

Thank you.

Hakik Zaman

Hi Fábio,

Thanks for reaching out to us. We have pushed our Swatches data for retrieving purposes on that endpoint only.

Unfortunately, it is not currently available. ​Please send the feature request here: https://storepress.fider.io/

and ask your other to upvote it.

Thank You