For e-commerce platforms like Venddor IO, flexibility is vital when setting product variations. Sometimes, certain product combinations may not be available, and you might not want customers to select them. For instance, a T-shirt might not be available in a specific color and size combination. This is where option exceptions come into play in Venddor IO.
Within Venddor IO, exceptions allow you to specify particular combinations of product options that customers can't select. It's worth noting that only those options having variants can be a part of an exception. This is typically limited to options like Checkbox, Select box, and Radiogroup.
There are two distinct kinds of exceptions:
The kind of exception linked to a product is identified by its exceptions_type field, which can either be A (allowed) or F (forbidden). By default, products are set to the forbidden type.
To retrieve all exceptions related to a particular product, send a GET request:
GET /api/exceptions/?product_id=12
On success, the response contains a JSON representation of all the exceptions linked to the mentioned product.
To get specifics of an exception, issue a GET request:
GET /api/exceptions/1
The exception details encompass fields such as exception_id (unique identifier), product_id (product linked with the exception), and combination (the actual combination of option variants forming the exception). Intriguingly, option variants can also have negative values like -1, indicating any variant of that option, or -2, meaning no variant can be selected.
Creating an exception is as simple as sending a POST request to /api/exceptions/. The POST data should include the product's unique ID and the combination of options and variants:
{
"product_id": "12",
"combination": {
"3": "-1",
"4": "19",
"17": "61"
}
}
Existing exceptions can be modified using a PUT request:
PUT /api/exceptions/10
This request will adjust the variants of the exception.
If you wish to eliminate an exception, a DELETE request is the way to go:
DELETE /api/exceptions/10?product_id=12