Handling and working with product variant option values is extremely important, especially for businesses dealing with products with multiple variants. And like the previous two videos to create a new variant we need variant option values. That’s why I made this video to show you how to retrieve and create variant option values using Postman
Retrieving Product Variant Option Values
In the blog How To Retrieve And Create A Product Variant Without Error 409, I showed you how to retrieve all variants of a product so you should re-read the blog post and get information about product ID and option ID.
After having the product ID and option ID. We can start to retrieve all product variant option values
Open a new request tab. Here, select GET and paste the URL:
Replace store hash with your store hash and product ID by the product id you want to see the variants
Now in the header section, fill in the information about:
- X-auth-token
- Accept
- Content-type
After all, click send button to see the result:
For example:
{
"data": [
{
"id": 115,
"label": "Red",
"sort_order": 0,
"value_data": null,
"is_default": false
},
{
"id": 116,
"label": "Green",
"sort_order": 1,
"value_data": null,
"is_default": false
},
{
"id": 117,
"label": "Blue",
"sort_order": 2,
"value_data": null,
"is_default": false
},
{
"id": 118,
"label": "Purple",
"sort_order": 4,
"value_data": null,
"is_default": true
},
{
"id": 119,
"label": "Black",
"sort_order": 4,
"value_data": null,
"is_default": false
}
],
"meta": {
"pagination": {
"total": 6,
"count": 6,
"per_page": 50,
"current_page": 1,
"total_pages": 1,
"links": {
"current": "?page=1&limit=50"
}
}
}
}
Code language: JSON / JSON with Comments (json)
Create A New Product Variant Option Value
Now let’s create a new Product Variant option value
With the same URL, you just have to change the request from GET to POST.
The header would not change anything, but you have to add the code in the body part
Here is an example:
{
"is_default": false,
"sort_order": 3,
"label": "white"
}
Code language: JSON / JSON with Comments (json)
After all, click send button to see the result:
{
"data": {
"id": 120,
"label": "White",
"sort_order": 3,
"value_data": null,
"is_default": false
},
"meta": {}
}
Code language: JSON / JSON with Comments (json)
The above are steps to retrieve and create product variant option values in BigCommerce Using Postman. Creating a new product variant option value is also not too hard. You need to follow the steps that I instructed above. If you have any difficulty or questions at any step, please comment below or refer to our BigCommerce API documentation if you have any questions.
Hope you are successful