在商家資訊中新增菜單後,顧客就能查看餐廳的菜單選項,並取得菜單品項的額外資訊。
如要更新商家資訊的菜單,請先呼叫 accounts.locations.getFoodMenus。以下是要求範例:
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/foodMenus
回應包含房源目前狀態的 JSON 表示法。
FoodMenus視需要修改 FoodMenus 物件,然後呼叫 accounts.locations.updateFoodMenus。詳情請參閱「上傳或更換菜單」。
你可以使用 Google 我的商家 API 更新下列欄位:
| 欄位 | |
|---|---|
| 名稱 | 必要 食品名稱,例如 |
| 價格 | 必要 食品項目的價格。 |
| 價格幣別 | 必要 餐點價格的幣別,例如 |
| 商品說明 | 選用 簡短說明餐點。 |
| 菜單專區 | 選用 食品項目的邏輯群組,例如 |
| 營養 | 選用 (建議) 營養資訊,例如 |
| 服務人數 | 選用 這項食品可供幾人食用。 |
| 份量 | 選用 餐點數量。例如: |
| 準備方法 | 選用 食物項目的特定烹調方式。 |
| 美食 | 選用 (建議) 食品項目的特定菜系。 |
| 辣度 | 選用 食物項目的辣度,例如 |
| 過敏原 | 選用 (建議) 食品中的食物過敏原,例如 |
| 飲食 | 選用 (建議) 食物項目的飲食限制,例如 |
| 選項 | 選用 食物選項類型,例如 |
| 食物品項相片 | 選用 特定食品項目的相片。 |
上傳或更換菜單
並非所有地點都能上傳菜單。
如要判斷地點是否符合資格,請呼叫 locations.get,檢查 Metadata。如果 canHaveFoodMenus 設為 true,你就能上傳菜單。
如果您的位置符合資格,請對 accounts.locations.updateFoodMenus 執行 PATCH 呼叫。
以下是包含所有選填欄位的要求範例:
PATCH
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/foodMenus
{
"menus": [
{
"cuisines": [
"AMERICAN"
],
"labels": [
{
"displayName": "Menu",
"description": "Main Menu of my Restaurant",
"languageCode": "en"
}
],
"sections": [
{
"labels": {
"displayName": "Main Dishes",
"languageCode": "en"
},
"items": [
{
"labels": {
"displayName": "Dish1",
"description": "Dish1 - our original dish!",
"languageCode": "en"
},
"attributes": {
"price": {
"currencyCode": "USD",
"units": 20
},
"dietaryRestriction": "ORGANIC",
"nutritionFacts": {
"calories": {
"lowerAmount": 400,
"upperAmount": 500,
"unit": "CALORIE"
},
"totalFat": {
"lowerAmount": 95,
"upperAmount": 110,
"unit": "GRAM"
},
"cholesterol": {
"lowerAmount": 100,
"upperAmount": 120,
"unit": "MILLIGRAM"
},
"sodium": {
"lowerAmount": 30,
"upperAmount": 45,
"unit": "MILLIGRAM"
},
"totalCarbohydrate": {
"lowerAmount": 78,
"upperAmount": 92,
"unit": "MILLIGRAM"
},
"protein": {
"lowerAmount": 25,
"upperAmount": 35,
"unit":"MILLIGRAM"
}
},
"ingredients": [
{
"labels": [
{
"displayName": "Ingredient 1",
"description": "Description for ingredient 1",
"languageCode": "en"
},
{
"displayName": "Ingredient 2",
"languageCode": "en"
}
]
}
],
"servesNumPeople": 1,
"preparationMethods": [
"BAKED",
"BOILED",
"FRIED"
],
"portionSize": {
"quantity": 2,
"unit": {
"displayName": "Pieces",
"languageCode": "en"
}
},
"mediaKeys": [
"AF1QipP_VOlJzXs2aOJ31234565cb2KPrvN"
]
},
"options": [
{
"labels":
{
"displayName": "Dish1 - spicy",
"description": "Dish1 - a spicy version of our dish!",
"languageCode": "en"
},
"attributes": {
"price": {
"currencyCode": "USD",
"units": 20
}
}
},
{
"labels":
{
"displayName": "Dish1 - mild",
"description": "Dish1 - a mild spiciness version of our dish!",
"languageCode": "en"
},
"attributes": {
"price": {
"currencyCode": "USD",
"units": 20
}
}
}
]
}
]
},
{
"labels": {
"displayName": "Desserts",
"languageCode": "en"
},
"items": [
{
"labels": {
"displayName": "Ice Cream",
"description": "2 scoops of delicious ice cream!",
"languageCode": "en"
},
"attributes": {
"price": {
"currencyCode": "USD",
"units": 20
}
}
}
]
}
]
}
]
}
將相片與食物項目建立關聯
如要將相片與餐點建立關聯,請先將相片上傳至商家檔案地點。
如要擷取相片,請呼叫 accounts.locations.media.list。以下是要求範例:
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media/
回應會包含商家資訊中每張圖片的 MediaKey,如下列範例所示:
{
"mediaItems": [
{
"name": "accounts/{accountId}/locations/{locationId}/media/{mediaKey}",
"mediaFormat": "PHOTO",
"locationAssociation": {
"category": "FOOD_AND_MENU"
},
…
}
如要將相片與食物項目建立關聯,請取得相片的 mediaKey,並在 FoodMenuItemAttributes 物件中提供。您可以提供多個 mediaKeys。詳情請參閱「上傳或更換菜單」。