In addition to regular positive option variant IDs, the Venddor API supports special negative values in certain contexts, particularly for product option exceptions. These negative values provide powerful logic for controlling option behavior.
The following special negative values can be used in the combination
object when working with option exceptions:
Value | Description |
---|---|
-1 |
Wildcard: Any variant of this option can be selected. This value is used to indicate that all variants of a particular option are acceptable in a given combination rule. |
-2 |
Exclusion: No variant of this option can be selected. This value is used to indicate that no variants of a particular option are acceptable in a given combination rule. |
Here's an example of an option exception using negative values:
{ "exception_id": "5", "product_id": "12", "combination": { "3": "16", "4": "-1", "17": "-2" } }
Let's break down the example above for a specific product scenario:
Assuming we have a T-shirt product with the following options:
3
= Size, with variant 16
being "XXL"4
= Color with various color variants17
= Gift Wrapping (checkbox option)This exception (assuming it's of the "Forbidden" type) would enforce the following rule:
"When a customer selects XXL size (variant 16), they can select any color (-1), but the Gift Wrapping option cannot be selected (-2)."
In the customer interface, this means:
When creating or updating option exceptions via the API, you can include negative values in the combination object as shown below:
Creates a new option exception for a product.
{ "exception_type": "F", // F = Forbidden "combination": { "3": "16", // Size = XXL "4": "-1", // Any color is allowed "17": "-2" // Gift wrapping is not allowed } }
Negative values in option combinations are particularly useful for: