My big commerce product detail
- My product has an id of 149 (product_id = 149)
- My product has an assigned option called sized (option_id = 72) which is a text field.
- My product has variant_id of 160 (assumed from the value of base_variant_id)
Add to cart
I call /api.bigcommerce.com/stores/{$$.env.store_hash}/v3/carts with the following body
{
"line_items": [
{
"quantity": 5,
"product_id": 149,
"variant_id": 160,
"option_selections": [
{
"option_id": 72,
"option_value": "test"
}
]
}
]
}
Response if I don't variant Id
The variant_id value is my product base_variant_id. I needed to add the variant_id otherwise the api call responds with
"errors": {
"variant": "This product has options, variant ID is required"
},
"status": 422,
"title": "Missing or incorrect required fields",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes"
}
Adding the variant_id got rid of the above error
Response with variant, but fails due to size option not set
When I make the POST api call, to add to the card, it complains that the sized option isn't set
{
"detail": "Please enter some text for the sized option.",
"status": 422,
"title": "Missing or incomplete product variant attributes",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes"
}
How do I set the sized options value?