Share items in different categories
This topic demonstrates the implementations of the syncStore API for reusing items in different categories.
Overview
In a store, the same single items can be reused by different categories. Reusing an item means sharing all the item information, including the modifier groups and add-on items.
Things to know:
- The same modifier group can be reused by different items.
- The same add-on item can be reused by different modifier groups.
- Nested loops are not allowed for modifier groups and add-on items, for example, groupA contains itemB while itemB contains groupA.
Use cases
Reuse a single item
The following sections demonstrate how to reuse existing or new single items and remove reused items from a category.
Reuse an existing item
To add an existing item to a category, pass only the item ID of the item, which is specified in the itemId parameter.
See the following example:
{
"requestId": "2022112221****",
"appId": "21020101154****",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_01",
"categories": [
{
"categoryId": "category_01",
"items": [
{
"itemId": "item_01"
}
]
}
]
}
]
}
}
Reuse and change an existing item
Reuse an existing item from other categories and make changes to the item with one API call:
- To add an existing item to a category, pass only the item ID.
- To make changes to the item, pass the new information for the item.
Note: The changes will take effect everywhere with the same item ID in a D-store, except for the item status, because the item status can be overloaded in the category.
See the following example:
- To reuse an existing item in the category (
category_01
), pass the item ID (item_01
). - To change the name of the item, specify the name.value object with a new value (
item_01-update
).
{
"requestId": "2022112221****",
"appId": "21020101154****",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_01",
"categories": [
{
"categoryId": "category_01",
"items": [
{
"itemId": "item_01",
"name": {
"value": {
"en-US": "item_01-update"
}
}
}
]
}
]
}
]
}
}
Reuse a new item
Add new items to a category and reuse the newly added items in other categories with one API call:
- To add a new item to a category, pass all the information needed for the item.
- To reuse the newly added item in other categories, pass only the item ID.
See the following example:
- To add the item (
item_01
) to the category (category_id_01
), specify the items parameter with complete item information. - To reuse the newly added item in another category (
DINE_IN_category_01
), pass only the item ID (item_01
).
{
"requestId": "2022112221****",
"appId": "21020101154****",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_01",
"categories": [
{
"categoryId": "category_id_01",
"items": [
{
"itemId": "item_01",
"name": {
"value": {
"en-US": "Nachos Deluxe Double Beef"
}
},
"status": "AVAILABLE",
"saleType": "SINGLE",
"originAmount": {
"currency": "SGD",
"value": "30000"
},
"saleAmount": {
"currency": "SGD",
"value": "1350"
},
"quantityRule": {
"min": 0,
"max": 99
},
"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
},
"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"
}
]
}
],
"contents": [
{
"type": "IMAGE",
"scene": "BACKGROUND",
"value": "https://omni.posplus-crm.com/Omni_FnbItem/item01/storeabc.png"
},
{
"type": "TEXT",
"scene": "DESCRIPTION",
"value": "{\"value\":{\"en-US\":\"delicious food\"}}"
}
],
"extendInfo": {
"subTitle": {
"value": {
"en-US": "delicious chicken"
}
},
"takeAwayFee": {
"currency": "SGD",
"value": 100
},
"serviceSchedules": [
{
"scheduleType": "DAILY",
"schedules": {
"FIXED": [
{
"startTime": "00:00+08:00",
"endTime": "23:59+08:00"
}
]
}
}
]
},
"modifierGroups": [
{
"groupId": "MODIFIERGROUP01",
"name": {
"value": {
"en-US": "Add-On"
}
},
"quantityRule": {
"min": 0,
"max": 12
},
"childItems": [
{
"itemId": "201002||300009||@CD",
"name": {
"value": {
"en-US": "Add Beef Patty"
}
},
"saleType": "ADDON",
"originAmount": {
"currency": "SGD",
"value": 0
},
"saleAmount": {
"currency": "SGD",
"value": 350
}
}
]
}
]
}
]
}
]
},
{
"menuId": "menu_id_02",
"categories": [
{
"categoryId": "DINE_IN_category_01",
"items": [
{
"itemId": "item_01"
}
]
}
]
}
]
}
}
Hide a reused item
To hide an item from a category, pass the item ID and specify the items.status parameter as REMOVED
.
For an item shared by multiple categories, if the item is hidden from one category, it still exists in other categories and is visible to users. The item is completely invisible to users only when it is hidden from all categories that share the item.
For example, the item (item_01
) is hidden from the category (DINE_IN_category_01
):
{
"requestId": "20221122211221",
"appId": "210201011541660",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_02",
"categories": [
{
"categoryId": "DINE_IN_category_01",
"items": [
{
"itemId": "item_01",
"status":"REMOVED"
}
]
}
]
}
]
}
}
Reuse a modifier group
In a store, the same modifier group can be reused by different items. Reusing a modifier group means sharing all the group information, including the add-on items.
To reuse an existing modifier group in an item:
- Pass all existing modifier groups (at least the group IDs) for the single item in the same order as before, otherwise, they will be removed from the item.
- For the modifier group to reuse, pass only the group ID of the modifier group (specified in the groupId parameter).
For example, the existing modifier group (MODIFIERGROUP01
) in the item (item_01
) is reused by another item (item_03
):
{
"requestId": "20221122211221",
"appId": "210201011541660",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_01",
"categories": [
{
"categoryId": "category_01",
"items": [
{
"itemId": "item_01",
"modifierGroups": [
{
"groupId": "MODIFIERGROUP01",
"name": {
"value": {
"en-US": "Add-On"
}
},
"quantityRule": {
"min": 0,
"max": 12
},
"childItems": [
{
"itemId": "201002||300009||@CD",
"name": {
"value": {
"en-US": "Add Beef Patty"
}
},
"saleType": "ADDON",
"originAmount": {
"currency": "SGD",
"value": 0
},
"saleAmount": {
"currency": "SGD",
"value": 350
}
}
]
}
]
},
{
"itemId": "item_03",
"modifierGroups": [
{
"groupId": "MODIFIERGROUP01"
}
]
}
]
}
]
}
]
}
}
Reuse an add-on item
In a store, the same add-on item can be reused by different modifier groups. Reusing an add-on item means sharing all the item information.
To reuse an existing add-on item in a modifier group:
- Pass all existing modifier groups (at least the group IDs) for the single item in the same order as before, otherwise, they will be removed from the item.
- For the target modifier group with an add-on item to reuse, pass all existing add-on items (at least the item IDs) in the same order as before.
- For the add-on item to reuse, pass only the item ID of the add-on item (specified in the itemId parameter).
For example, the existing add-on item (201002||300009||@CD
) in the modifier group (MODIFIERGROUP01
) is reused by another modifier group (MODIFIERGROUP02
). Make sure the two modifier groups have been synchronized before, otherwise, you should include all the information needed for the modifier groups.
{
"requestId": "20221122211221",
"appId": "210201011541660",
"store": {
"storeId": "20221017storeid01",
"menus": [
{
"menuId": "menu_id_01",
"categories": [
{
"categoryId": "category_01",
"items": [
{
"itemId": "item_01",
"modifierGroups": [
{
"groupId": "MODIFIERGROUP01",
"childItems": [
{
"itemId": "201002||300009||@CD",
"name": {
"value": {
"en-US": "Add Beef Patty"
}
},
"saleType": "ADDON",
"originAmount": {
"currency": "SGD",
"value": 0
},
"saleAmount": {
"currency": "SGD",
"value": 350
}
}
]
}
]
},
{
"itemId": "item_03",
"modifierGroups": [
{
"groupId": "MODIFIERGROUP02",
"childItems": [
{
"itemId": "201002||300009||@CD",
"name": {
"value": {
"en-US": "Add Beef Patty"
}
}
}
]
}
]
}
]
}
]
}
]
}
}