您在商家資訊中加入美食菜單後,客戶就能知道餐廳有哪些菜單選項,還可取得菜單品項的其他相關資訊。
如要更新商家資訊中的菜單,請先呼叫 accounts.locations.getFoodMenus
。
以下是要求範例:
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/foodMenus
回應包含清單目前 FoodMenus
的 JSON 表示法。視需要修改 FoodMenus
物件並呼叫 accounts.locations.updateFoodMenus
。詳情請參閱上傳或取代食物菜單。
您可以使用 Google My Business API 更新下列欄位:
欄位 | |
---|---|
名稱 | 必要 食物項目名稱,例如 |
價格 | 必要 食品的價格。 |
價格幣別 | 必要 食品價格的貨幣,例如 |
Item description | 選用 食物商品的簡要說明。 |
菜單專區 | 選用 邏輯食品群組,例如 |
營養 | 選填 (建議) 營養資訊,例如 |
服務人數 | 選用 食品可服務的人數。 |
單元大小 | 選用 食品的數量。例如: |
準備方法 | 選用 可供準備食品的具體方法。 |
美食 | 選填 (建議) 食物項目的特定料理。 |
辣度 | 選用 食物品味,例如 |
過敏原 | 選填 (建議) 食品中的食物過敏原,例如 |
飲食 | 選填 (建議) 食品的飲食限制,例如 |
選項 | 選用 餐點選項類型,例如 |
食物品項相片 | 選用 特定食品的相片。 |
上傳或取代飲食菜單
並非所有地點都能上傳美食菜單。
如要確認地點是否符合使用資格,請呼叫 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
。詳情請參閱上傳或取代食物菜單。