Reputation: 23
I am using Bigcommerce v3 API to create products on bigcommerce store. I have a product with two variants having following options
Size Self Life Dot info
1L Glass Amber
500ml Glass Amber 12 Methanol Sol.
When I am trying to create product like this
{
"name": "Product name",
"type": "physical",
"sku": "CDID-12345",
"description": "Description",
"weight": 0,
"width": 0,
"depth": 0,
"height": 0,
"price": 0,
"cost_price": 0,
"retail_price": 0,
"sale_price": 0,
"categories": [1],
"variants": [
{
"cost_price": 0,
"price": 0,
"weight": 0,
"sku": "MP091236",
"option_values": [
{
"option_display_name": "Size",
"label": "1L Glass Amber",
}
]
},
{
"cost_price": 0,
"price": 0,
"weight": 0,
"sku": "MP091239",
"option_values": [
{
"option_display_name": "Size",
"label": "500ml Glass Amber",
},
{
"option_display_name": "Self Life",
"label": "12",
},
{
"option_display_name": "Dot Info",
"label": "Methanol Sol.",
}
]
}
]
}
then I am getting error:
Variants must have the the same list option display names.
And when I am passing parameters like this:
{
"name": "Product name",
"type": "physical",
"sku": "CDID-12345",
"description": "Description",
"weight": 0,
"width": 0,
"depth": 0,
"height": 0,
"price": 0,
"cost_price": 0,
"retail_price": 0,
"sale_price": 0,
"categories": [1],
"variants": [
{
"cost_price": 0,
"price": 0,
"weight": 0,
"sku": "MP091236",
"option_values": [
{
"option_display_name": "Size",
"label": "1L Glass Amber",
},
{
"option_display_name": "Self Life",
"label": "",
},
{
"option_display_name": "Dot Info",
"label": "",
}
]
},
{
"cost_price": 0,
"price": 0,
"weight": 0,
"sku": "MP091239",
"option_values": [
{
"option_display_name": "Size",
"label": "500ml Glass Amber",
},
{
"option_display_name": "Self Life",
"label": "12",
},
{
"option_display_name": "Dot Info",
"label": "Methanol Sol.",
}
]
}
]
}
then I am getting error like this:
"variants.0.option_values.1.label": "label must be a string"
How can I create two SKUs of this product where one will have options Size , Self Life and Dot info and other having Size as only option.
Upvotes: 0
Views: 180
Reputation: 26
In this case seems like you want Self Life
and be Dot Info
as non required modifiers instead rather than as options
Basically you will create 2 variants each having option values as shown below on above endpoint
"variants": [
{
...
"option_values": [
{
"option_display_name": "Size",
"label": "1L Glass Amber",
}
]
}
{
...
"option_values": [
{
"option_display_name": "Size",
"label": "500ml Glass Amber",
}
]
}
and then create 2 modifiers (one with display_name
: Self Life
other with display_name
: Dot Info
) by posting twice on v3/catalog/products//modifiers
Upvotes: 1