Set category sequence
This topic demonstrates the implementations of the syncStore API to set the sequence of categories displayed to users.
Overview
To set the sequence of categories in a menu, specify the categories.sequence parameter for each category.
Things to know:
- The minimum value is
0
, which means a category is displayed in the first position. - When inserting data, the default value is
9999
if no value is specified. - Categories with the same value for the sequence parameters are not sorted.
Use cases
Set sequence for existing categories
You can set the sequence for existing categories that have been synchronized via the syncStore API.
As the following example shows, the sequence (from 1 to 4) of the existing categories in the menu (menu_id_01
) is category_id_01
, category_id_02
, category_id_03
, and category_id_04
:
{
"requestId": "12222211****",
"appId": "21020101154****",
"store": {
"storeId": "20221001storeid04", // (Mandatory)The store where the category belongs to
"menus": [
{
"menuId": "menu_id_01", // (Mandatory)The menu where the category belongs to
"categories": [
{
"categoryId": "category_id_01", // (Mandatory)The category to set sequence
"sequence":1 // (Mandatory)The sequence and the default value is 9999
},
{
"categoryId": "category_id_02",
"sequence":2
},
{
"categoryId": "category_id_03",
"sequence":3
},
{
"categoryId": "category_id_04",
"sequence":4
}
]
}
]
}
}
Move a category to the first position
To move a category to the first position, specify the sequence parameter of the category as 0
. It is recommended to specify only one category with a sequence parameter value of 0
, otherwise, the category will not be moved to the first position.
For example, the category (category_id_01
) is moved to the first position:
{
"requestId": "12222211****",
"appId": "21020101154****",
"store": {
"storeId": "20221001storeid04", // (Mandatory)The store where the category belongs to
"menus": [
{
"menuId": "menu_id_01", // (Mandatory)The menu where the category belongs to
"categories": [
{
"categoryId": "category_id_01", // (Mandatory)The category to set sequence
"sequence":0
}
]
}
]
}
}