Carts

前置準備

在使用購物車相關 API 前,請先準備對應的商店代碼 handle 以及 Storefront API 的 token
To use the Cart APIs, you will need the store's handle and Storefront API token.

  • 商店代碼 handle:可透過 Get Merchant API 取得
    Store Handle (handle): Retrieve it via the Get Merchant API.
  • Storefront API token:請參閱 Storefront API 文件說明
    Storefront API token: Please refer to the Storefront API documentation for details on how to obtain this token.

使用說明

以下以顧客結帳流程為例,說明 Cart API 的使用場景(詳細欄位定義與請求範例,請參閱對應的 API 文件):
The following example outlines a typical customer checkout flow to demonstrate how Cart APIs are used. (For detailed parameter descriptions and request examples, please refer to each API’s documentation.)

顧客 [1] 將商品加入購物車 → [2] 查看購物車 → [3] 更改購物車內的商品數量 → [4] 刪除購物車內的商品
Customer actions: [1] Add items to cart → [2] View cart → [3] Update items quantity → [4] Remove items from cart

[1] 將商品加入購物車 Add items to cart

  1. 透過 Exchange Cart Id API 拿取顧客對應的購物車 id
    Use the Exchange Cart Id API to obtain the corresponding cartId for the customer.
  2. 使用 Add Items to Cart API 將商品加入購物車
    Use the Add Items to Cart API to add products to the cart.

[2] 查看購物車 View cart

  • 透過 Prepare Cart API 取得目前購物車內的商品明細
    Use the Prepare Cart API to retrieve the current contents of the cart.

[3] 更改購物車內的商品數量 Update items quantity

[4] 刪除購物車內的商品 Remove items from cart