Add Product Variants
POST
v1/products/{product_id}/options/This endpoint creates child variants for a given product by defining choices for its attributes. If the product in question is a stand-alone product (neither a parent nor having any children), this operation will transform it into a parent product.
Steps to Create Variants:
- Create Product Attributes: Begin by creating product attributes for the store using the Create Attribute endpoint.
- Define Attribute Choices: Next, define choices for these attributes. For example, for a size attribute, choices might include 'small', 'medium', 'large', etc.
- Choice Objects in Different Languages: Each choice is an object that accepts values in multiple languages. Currently, English and Arabic are supported.
- Submit Attributes and Choices: This endpoint accepts an array of attributes and their respective choices.
- Variant Generation: Variants are then created using the cartesian product of these attribute values, resulting in all possible combinations.
Request
The Authorization token is a unique key given to the third-party application (Partner) by Zid. It is used to authenticate the API requests made by the Partner application. The token verifies the partner's identity and ensures they have permission to access Zid's API but does not provide any specific user or store information. It should be included in the header of API requests when the partner application needs to access Zid's API.
This token is used to authenticate and access information related to the store. It is obtained through an OAuth mechanism and is required to perform operations on the store's data. The X-Manager-Token
should be included in the header of API requests that require store-related information.
Localized names of the product in Arabic (ar
) and English (en
).
An array of objects, each representing a product variant.
You can specify existing variants to update by including their IDs,
or add new variants by omitting the ID field.
The ID of the variant to update. Omit this field to add a new variant.
Flag to indicate if the variant should be deleted.
Stock Keeping Unit identifier for the variant.
Price of the variant.
Sale price of the variant, if applicable.
Array of image URLs for the variant.
Quantity of the variant available.
Flag to indicate if the variant has infinite stock.
Weight of the product.
Additional stock information for the variant. For more information, refer to the ProductStocks schema.
The attributes
array is a key field that defines the unique characteristics of each product variant. For a comprehensive understanding of how to use this field, please refer to the Product Options Documentation.
{
"name2": "string",
"id": "string",
"name": {
"ar": "حذاء رياضي (عمالة منصفة)",
"en": "Sneakers (Fair Trade)"
},
"variants": [
{
"id": "49ef6116-f094-56ec-7aha-es6sf771f829",
"is_deleted": false,
"sku": "Z.987654.1234567890",
"price": 1400,
"sale_price": 1200,
"images": [
"image1.jpg",
"image2.jpg"
],
"quantity": 70,
"is_infinite": false,
"weight": {
"value": 1.2,
"unit": "kg"
},
"stocks": [
null
],
"attributes": [
{
"slug": "color",
"value": {
"ar": "أبيض",
"en": "White"
}
}
]
}
]
}