客戶提交訂單後,你可以傳送訂單更新訊息給 Google,通知客戶訂單有異動。Google 會在訂購 UI 中將這則訊息轉寄給消費者。
傳送訂單更新的常見原因包括:
- 訂單的預估交貨時間會顯示或變更。
- 訂單狀態會變更。
- 系統無法再處理訂單。
- 訂單中包含的菜單項目價格有所異動。
- 客戶可以透過新方式管理訂單,例如客戶服務或餐廳電話號碼。
- 訂單的收據會隨即顯示。
舉例來說,下列範例使用訂單更新功能,在餐廳確認訂單後,將客戶訂單的狀態從 CREATED
變更為 CONFIRMED
:
用途 | 實作方式 |
---|---|
用途 1:餐廳確認訂單 | 系統會將狀態為 CONFIRMED 的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 estimatedFulfillmentTime 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CONFIRMED", "label": "Provider confirmed" }, "receipt": { "userVisibleOrderId": "userVisibleId1234" }, "updateTime": "2017-07-17T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z" } } } }
如要瞭解如何為專案實作訂單更新功能,請參閱「非同步訂單更新」指南。
接下來幾節將提供更進階的訂單更新情境範例。
已拒絕狀態
以下範例示範因各種原因遭拒的訂單的 AsyncOrderUpdateRequestMessage
。拒絕原因的例子包括餐廳無法再處理訂單,或是與訂單相關聯的運送地址超出範圍。
用途 | 實作方式 |
---|---|
用途 1:供應商無法聯絡餐廳或餐廳無法處理訂單,因此訂單遭到拒絕。 | 將狀態為 REJECTED 的 OrderUpdate 傳送給 Google。必須具備錯誤類型 NO_CAPACITY 的 actionOrderId 、userVisibleOrderId 、orderManagementActions 、rejectionInfo 和 foodOrderError 。 |
用例 2:由於沒有可用的駕駛員或送達地址超出範圍,因此訂單遭到拒絕。 | 將狀態為 REJECTED 的 OrderUpdate 傳送給 Google。必須具備錯誤類型 OUT_OF_SERVICE_AREA 的 actionOrderId 、userVisibleOrderId 、orderManagementActions 、rejectionInfo 和 foodOrderError 。 |
用途 3:餐廳因意外關閉或即將關閉,導致訂單遭到拒絕。 | 將狀態為 REJECTED 的 OrderUpdate 傳送給 Google。必須具備錯誤類型 CLOSED 的 actionOrderId 、userVisibleOrderId 、orderManagementActions 、rejectionInfo 和 foodOrderError 。 |
用例 4:部分商品缺貨,因此訂單遭到拒絕。 | 將狀態為 REJECTED 的 OrderUpdate 傳送給 Google。必須具備錯誤類型 AVAILABILITY_CHANGED 的 actionOrderId 、userVisibleOrderId 、orderManagementActions 、rejectionInfo 和 foodOrderError 。 |
用途 5:訂單因不明或未分類的原因而遭拒。 | 將狀態為 REJECTED 的 OrderUpdate 傳送給 Google。必須具備錯誤類型 UNKNOWN 的 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 rejectionInfo 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, the restaurant cannot take your order right now." }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "foodOrderErrors": [ { "error": "NO_CAPACITY", "description": "Sorry, the restaurant cannot take your order right now." } ] } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, delivery is currently not available to your address." }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "foodOrderErrors": [ { "error": "OUT_OF_SERVICE_AREA", "description": "Sorry, delivery is currently not available to your address." } ] } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, the restaurant is closed unexpectedly." }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "foodOrderErrors": [ { "error": "CLOSED", "description": "Sorry, the restaurant is closed unexpectedly." } ] } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, some of items are not available right now." }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "foodOrderErrors": [ { "error": "AVAILABILITY_CHANGED", "id": "sample_menu_item_id", "description": "Sorry, some of the items are not available right now." } ] } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, your order is rejected." }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ] } } }
已取消狀態
以下範例說明客戶要求取消的訂單的 AsyncOrderUpdateRequestMessage
。
用途 | 實作方式 |
---|---|
用途 1:客戶要求取消訂單 | 將狀態為 CANCELLED 的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 cancellationInfo 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CANCELLED", "label": "Order cancelled" }, "updateTime": "2017-05-10T02:30:00.000Z", "cancellationInfo": { "reason": "Customer requested" }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ] } } }
已完成狀態
以下範例說明已完成訂單的 AsyncOrderUpdateRequestMessage
。
用途 | 實作方式 |
---|---|
用途 1:訂單已完成 | 將狀態為 FULFILLED 的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 和 orderManagementActions 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "FULFILLED", "label": "Order delivered" }, "updateTime": "2017-05-10T02:30:00.000Z", "fulfillmentInfo": { "deliveryTime": "2017-05-10T02:30:00.000Z" }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ] } } }
運送中狀態
以下範例說明如何為運送至客戶的訂單建立 AsyncOrderUpdateRequestMessage
。
用途 | 實作方式 |
---|---|
用途 1:運送訂單正在運送中。 | 將狀態為 IN_TRANSIT 的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 estimatedFulfillmentTime 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "IN_TRANSIT", "label": "Order is on the way" }, "inTransitInfo": { "updatedTime": "2017-07-17T12:00:00Z" }, "updateTime": "2017-07-17T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "PT20M" } } } }
可取貨狀態
以下範例說明可供消費者取貨的訂單的 AsyncOrderUpdateRequestMessage
。
用途 | 實作方式 |
---|---|
用途 1:訂購商品已可取貨。 | 將具有 READY_FOR_PICKUP 狀態的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 estimatedFulfillmentTime 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "READY_FOR_PICKUP", "label": "Order is ready for pickup" }, "updateTime": "2018-04-15T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "PT20M" } } } }
食物準備狀態
以下範例說明餐廳正在準備的訂單的 AsyncOrderUpdateRequestMessage
。
用途 | 實作方式 |
---|---|
用途 1:餐廳正在準備訂購的餐點。 | 將具有 IN_PREPARATION 狀態的 OrderUpdate 傳送給 Google。必須具備 actionOrderId 、userVisibleOrderId 、orderManagementActions 和 estimatedFulfillmentTime 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "IN_PREPARATION", "label": "Order is being prepared" }, "updateTime": "2018-04-15T11:30:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "PT20M" } } } }
訂單狀態已變更
以下範例說明如何針對客戶訂單的各種變更建立 AsyncOrderUpdateRequestMessage
。
用途 1:需要更新預估完成時間。 | 將 OrderUpdate 傳送至 Google,並附上訂單狀態、actionOrderId 、userVisibleOrderId 、orderManagementAction 和更新後的 estimatedFulfillmentTime 。 |
用途 2:需要更新訂單的總價。 | 將 OrderUpdate 傳送至 Google,並附上訂單狀態、actionOrderId 、userVisibleOrderId 、orderManagementAction 、estimatedFulfillmentTime 和更新後的 totalPrice 。 |
用途 3:需要更新訂單的訂單管理動作。 | 將 OrderUpdate 傳送至 Google,並附上訂單狀態、actionOrderId 、userVisibleOrderId 、estimatedFulfillmentTime 和更新後的 orderManagementActions 。 |
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CONFIRMED", "label": "Provider confirmed" }, "receipt": { "userVisibleOrderId": "userVisibleId1234" }, "updateTime": "2017-07-17T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z" } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CONFIRMED", "label": "Provider confirmed" }, "receipt": { "userVisibleOrderId": "userVisibleId1234" }, "totalPrice": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "20", "nanos": 500000000 } }, "updateTime": "2017-07-17T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z" } } } }
JSON
{ "isInSandbox": true, "customPushMessage": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CONFIRMED", "label": "Provider confirmed" }, "receipt": { "userVisibleOrderId": "userVisibleId1234" }, "updateTime": "2017-07-17T12:00:00Z", "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:person@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "CALL_DRIVER", "button": { "title": "Call driver", "openUrlAction": { "url": "tel:+16505554681" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z" } } } }