Set item or SKU availability

This topic demonstrates the implementations of the syncStore API for specifying item or SKU availability.

Overview

You can specify item or SKU availability if an item or SKU is unavailable during particular seasons or periods. For example, crabs are only available from September to December.

Use cases

Set item availability

To set item availability, specify the items.bizRules.scene parameter as ITEM_STATUS_RULE and the ruleData parameter with specific rules.

For example, from 2022-09-01T00:00:01+08:00 to 2022-12-31T23:59:59+08:00, the item (item_01) is only available from 10:00 to 14:00 on Mondays, Tuesdays, and Wednesdays.

copy
{
    "requestId": "20221122211***",
    "appId": "21020101154***",
    "store": {
        "storeId": "20221017storeid01",
        "menus": [
            {
                "menuId": "menu_id_01",
                "categories": [
                    {
                        "categoryId": "category_id_01",
                        "items": [
                            {
                                "itemId": "item_01",
                                "bizRules": [
                                    {
                                        "scene": "ITEM_STATUS_RULE",
                                        "ruleData": "[{\"from\":\"2022-09-01T00:00:01+08:00\",\"to\": \"2022-12-31T23:59:59+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00+08:00\",\"endTime\": \"14:00+08:00\"},\"itemStatus\":\"AVAILABLE\"}]"
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

The following example demonstrates the above ruleData parameter value before serialization:

copy
[
    {
        "from": "2022-09-01T00:00:01+08:00",
        "to": "2022-12-31T23:59:59+08:00",
        "weekDays": [
            "MONDAY",
            "WEDNESDAY",
            "TUESDAY"
        ],
        "timeSlot": {
            "startTime": "10:00+08:00",
            "endTime": "14:00+08:00"
        },
        "itemStatus": "AVAILABLE"
    }
]

Set SKU availability

To set SKU availability, specify the skus.bizRules.scene parameter as SKU_STATUS_RULE and the ruleData parameter with specific rules.

Note: Be sure to pass both the skus and skuPropertyGroups arrays. For more information about key-value pairs in the skus.skuPropertyPairs parameter, see Change skus or skuPropertyGroups.

For example, from 2022-09-01T00:00:01+08:00 to 2022-12-31T23:59:59+08:00, the SKU (tsku2121) is only available from 10:00 to 14:00 on Mondays, Tuesdays, and Wednesdays.

copy
{
    "requestId": "20221122211***",
    "appId": "21020101154***",
    "store": {
        "storeId": "20221017storeid01",
        "menus": [
            {
                "menuId": "menu_id_01",
                "categories": [
                    {
                        "categoryId": "category_id_01",
                        "items": [
                            {
                                "itemId": "item_01",
                                "skuPropertyGroups": [
                                    {
                                        "name": {
                                            "value": {
                                                "en-US": "size"
                                            }
                                        },
                                        "skuGroupId": "27731",
                                        "properties": [
                                            {
                                                "name": {
                                                    "value": {
                                                        "en-US": "Small"
                                                    }
                                                },
                                                "propertyId": "Small"
                                            },
                                            {
                                                "name": {
                                                    "value": {
                                                        "en-US": "Large"
                                                    }
                                                },
                                                "propertyId": "Large"
                                            }
                                        ]
                                    },
                                    {
                                        "skuGroupId": "27733",
                                        "name": {
                                            "value": {
                                                "en-US": "Level of Spiciness"
                                            }
                                        },
                                        "properties": [
                                            {
                                                "name": {
                                                    "value": {
                                                        "en-US": "No Chili"
                                                    }
                                                },
                                                "propertyId": "No Chili"
                                            },
                                            {
                                                "name": {
                                                    "value": {
                                                        "en-US": "less Chili"
                                                    }
                                                },
                                                "propertyId": "Less Chili"
                                            },
                                            {
                                                "name": {
                                                    "value": {
                                                        "en-US": "Normal Chili"
                                                    }
                                                },
                                                "propertyId": "Normal Spicy"
                                            }
                                        ]
                                    }
                                ],
                                "skus": [
                                    {
                                        "skuId": "tsku2121",
                                        "skuPropertyPairs": {
                                            "27731": "Small",
                                            "27733": "Normal Spicy"
                                        },
                                        "originAmount": {
                                            "currency": "SGD",
                                            "value": 100
                                        },
                                        "saleAmount": {
                                            "currency": "SGD",
                                            "value": 90
                                        },
                                        "bizRules": [
                                            {
                                                "scene": "SKU_STATUS_RULE",
                                                "ruleData": "[{\"from\":\"2022-09-01T00:00:01+08:00\",\"to\": \"2022-12-31T23:59:59+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00+08:00\",\"endTime\": \"14:00+08:00\"},\"skuStatus\":\"AVAILABLE\"}]"
                                            }
                                        ],
                                        "contents": [
                                            {
                                                "type": "IMAGE",
                                                "scene": "BACKGROUND",
                                                "value": "https://www.example.com/images/uploads/meals/test.JPG"
                                            }
                                        ]
                                    },
                                    {
                                        "skuId": "tsku2122",
                                        "skuPropertyPairs": {
                                            "27731": "Large",
                                            "27733": "Normal Spicy"
                                        },
                                        "originAmount": {
                                            "currency": "SGD",
                                            "value": 100
                                        },
                                        "saleAmount": {
                                            "currency": "SGD",
                                            "value": 80
                                        },
                                        "contents": [
                                            {
                                                "type": "IMAGE",
                                                "scene": "BACKGROUND",
                                                "value": "https://wwww.example.com/images/uploads/meals/test.png"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

The following example demonstrates the above ruleData parameter value before serialization:

copy
[
    {
        "from": "2022-09-01T00:00:01+08:00",
        "to": "2022-12-31T23:59:59+08:00",
        "weekDays": [
            "MONDAY",
            "WEDNESDAY",
            "TUESDAY"
        ],
        "timeSlot": {
            "startTime": "10:00+08:00",
            "endTime": "14:00+08:00"
        },
        "skuStatus": "AVAILABLE"
    }
]