ProductVariant_Insert
#
Description#
This function inserts a new product variant.
Request Parameters#
Parameter |
Type | Description |
---|---|---|
product_id Edit_Product Product_Code Product_SKU |
Number String String String |
ID Number of product Product code string Product code string Product SKU string |
attribute_ids |
Number | The attribute id of the product |
AttributeTemplateattribute_ids |
Number | The attribute template ids of the product attribute |
option_ids |
Number | The option id numbers of the product |
part_ids |
Number | The id numbers of the product parts |
quantities |
Number | The part quantities for the product variant |
attributes |
Object | Object containing the attribute codes and options |
attr_code |
String | String of attribute code assigned to variant |
option_code |
String | String of option code assigned to variant |
parts |
Object | Object containing the part codes and quantities |
part_code |
String | String of part product code assigned to variant |
quantity |
Number | Number of parts assigned to variant |
pricing |
Object | Object containing the pricing settings |
method |
String / Number | “master”/0 “specific”/1 “sum”/2 |
price |
Number | Number containing the price of the variant |
cost |
Number | Number containing the cost of the variant |
weight |
Number | Number containing the weight of the variant |
attributes
Object#
Parameter |
Type | Description |
---|---|---|
attr_id |
Number | Attribute ID |
option_id |
Number | Option ID |
parts
Object#
Parameter |
Type | Description |
---|---|---|
part_id |
Number | Part ID |
quantity |
Number | Quantity of Part |
pricing
Object#
Parameter |
Type | Description |
---|---|---|
part_id |
Number | Part ID |
quantity |
Number | Quantity of Part |
Note
When the Pricing object exists, only the method
member should be required, with the other 3 members all optional. Price
, cost
, and weight
should all have default values of 0.00.
Response Parameters#
Parameter |
Type | Description |
---|---|---|
success |
Boolean | Boolean value indicating if the API request was successful |
product_id |
Number | The product id for the variant |
variant_id |
Number | The new variant id |
Example Request#
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "ProductVariant_Insert",
"Product_ID": 1,
"Attribute_IDs": 9,
"AttributeTemplateAttribute_IDs": 1,
"Option_IDs": 1,
"Part_IDs": 206,
"Quantities": 1,
"Attributes": [
{
"attr_code": "ATRIBUTE_CODE",
"option_code": "OPTION_CODE"
},
{
"attr_code": "ATRIBUTE_CODE",
"option_code": "OPTION_CODE"
}
],
"Parts": [
{
"part_code": "PART_PRODCUCT_CODE",
"quantity": 1
},
{
"part_code": "PART_PRODCUCT_CODE",
"quantity": 1
}
],
"Pricing" :
{
"method": "master/specific/sum/0/1/2",
"price": 10,
"cost": 10,
"weight": 10
}
}
Example Response#
{
"success": 1,
"data": {
"product_id": 1737,
"variant_id": 38,
"option_id_36_0": 59,
"option_code_36_0": "OPTION_CODE",
"attributes": [
{
"attr_id": 36,
"attr_code": "ATRIBUTE_CODE",
"attmpat_id": 0,
"option_id": 59,
"option_code": "OPTION_CODE"
}
],
"parts": [
{
"product_id": 1793,
"product_code": "PART_PRODCUCT_CODE",
"product_sku": "",
"product_name": "PART_PRODCUCT_NAME",
"quantity": 1
}
]
}
}