Managing Product Option Combinations in Venddor IO

Introduction

To facilitate inventory tracking, Venddor IO allows products to be grouped into option combinations. Consider selling clothes in various colors and sizes. It becomes easier to track how many blue XL T-shirts or white M T-shirts you have in stock. These combinations even enable you to segregate by code and image.

For an option to be part of these combinations in Venddor IO, it must have the 'Inventory' checkbox activated, denoted by inventory=Y. This is primarily available for Checkbox, Select box, and Radiogroup types.

A Guide to Option Combinations

Viewing Product's Option Combinations

To fetch a list of option combinations for a product, initiate a GET request:

GET /api/combinations/?product_id=12

A successful request provides a list of all option combinations for that product.

Pagination

For controlling the number of option combinations in the response, you can use parameters:

For instance:

GET /api/combinations/?product_id=12&items_per_page=2&page=3

This request will yield 2 option combinations from the third page.

Interpreting the Response

On sending a test request like:

GET /api/combinations/?product_id=12&items_per_page=2

A successful response, besides being HTTP/1.1 200 OK, contains pertinent data about the combination, including product id, combination hash, associated options, and image details.

Retrieving a Specific Combination

To get in-depth details of a particular option combination, dispatch a GET request:

GET /api/combinations/822274303

This yields a detailed JSON response of that combination.

Understanding Combination Details

Various elements form an option combination. For instance, product_id denotes the associated product, combination_hash signifies the unique combination id, and combination represents the exact combination of options.

Creating an Option Combination

To form a new combination, a POST request to /api/combinations/ is necessary. The request body must include the product id and the specific combination of options:

{
    "product_id": "4",
    "combination": {
        "24": "74",
        "25": "80",
        "26": "86"
    },
    "amount": "34",
    "position": "10"
}

If executed correctly, you'll receive a combination hash as confirmation.

Modifying an Option Combination

Existing combinations can be adjusted using a PUT request:

PUT /api/combinations/2822626827

This can alter elements like stock amount, product code, or its position on a list.

Deleting an Option Combination

To remove a specific option combination, a DELETE request with the product ID (to verify permissions) is needed:

DELETE /api/combinations/2822626827?product_id=4