# 购物车创建

**Webhook** cart/create

购物车新增商品时触发。

需要 `order` [访问权限](/zh-CN/docs/app/building-blocks/authentication/access-scopes)。最低支持版本：`202201`。

## 请求头

- `X-Shoplazza-Topic` string

  触发本次推送的事件，例如 orders/create

  **示例：** `orders/create`
- `X-Shoplazza-Hmac-Sha256` string

  请求体的 HMAC-SHA256 签名（base64 编码），使用应用的 Client Secret 生成，用于验证请求来自 Shoplazza
- `X-Shoplazza-Shop-Domain` string

  产生该事件的店铺域名

  **示例：** `example.myshoplaza.com`
- `X-Shoplazza-Api-Version` string

  序列化 payload 使用的 API 版本

  **示例：** `2025-06`
- `X-Shoplazza-Deduplication-ID` string

  本次推送的去重 ID，同一事件重发时保持不变，用于幂等去重

## 请求体

**数据结构 | 示例**

- `cart` object

  - `created_at` string

    购物车创建时间
  - `currency_code` string

    货币代码
  - `discount_applications` object[]

    购物车优惠明细

    *   Array \[

    - `apply_method` string

      自动活动行的应用方式
    - `code` string

      优惠码 code（仅优惠码活动有）
    - `discount_amount` number

      优惠金额
    - `discount_id` string

      优惠 ID
    - `discount_message` string

      优惠提示文案
    - `discount_text` string

      优惠文案（可能是 title 或 label）
    - `discount_type` string

      优惠码折扣类型：折扣 / 固定减价（仅优惠码有）
    - `entitled_product_list` undefined[]

      优惠作用商品列表
    - `extents` object

      扩展字段（string→string 键值对，键不固定）
    - `extents.application_time` string

      应用时间
    - `extents.business_custom_data` string

      业务自定义数据
    - `extents.discount_apply_type` string

      折扣应用类型
    - `extents.discount_code` string

      折扣码
    - `extents.discount_rule_info` string

      折扣规则信息
    - `extents.old_discount_id` string

      旧优惠 ID
    - `extents.use_with_other` string

      是否可与其他折扣叠加
    - `icon` string

      图标
    - `is_free_gift` boolean

      活动优惠商品列表是否为免费赠品
    - `message` string

      输入框提示文案
    - `properties` string

      优惠码附加字段
    - `status` string

      优惠码应用状态：success（应用成功）、undetermined（待定）、fail（应用失败）
    - `subtype` string

      营销活动子类型：discount\_rebate（满减）、discount\_code（优惠码）、discount\_coupon（优惠券）、discount\_flashsale（限时促销）、automatic（自动优惠）、buy\_x\_get\_y（买 X 送 Y）
    - `target_selection` string

      优惠目标选择方式
    - `target_type` string

      优惠作用目标：shipping\_line（运费）、line\_item（商品行）、payment\_line（支付方式）
    - `title` string

      优惠名称
    - `type` string

      营销活动类型：discount\_rebate（满减）、discount\_code（优惠码）、discount\_coupon（优惠券）、discount\_flashsale（限时促销）、automatic（自动优惠）
    - `value_type` string

      优惠值类型
    *   \]
  - `extra` object

    购物车变更附加信息

    - `client_id` string

      客户端 ID
  - `item_count` integer

    商品数量
  - `line_items` object[]

    购物车商品列表

    *   Array \[

    - `add_quantity` string

      添加数量
    - `available` boolean

      商品是否可售
    - `available_quantity` integer

      可用数量
    - `can_buy` boolean

      是否可购买
    - `compare_at_price` string

      商品原价（划线价）-单价
    - `cost_price` string

      成本价
    - `custom` boolean

      是否为自定义商品项
    - `discount_applications` object[]

      该商品项的优惠明细

      *   Array \[

      - `allocation_method` string

        分配方式
      - `code` string

        优惠码 code
      - `discount_amount` string

        折扣金额
      - `discount_id` string

        优惠 ID
      - `discount_quantity` integer

        优惠数量
      - `discount_text` string

        优惠文案（可能是 title 或 label）
      - `discount_type` string

        优惠码折扣类型
      - `extents` object

        扩展字段（键值对，键不固定）
      - `extents.business_custom_data` string

        业务自定义数据
      - `extents.old_discount_id` string

        旧优惠 ID
      - `extents.raw_input_line_item_price` string

        原始输入的行项目价格
      - `groups` undefined[]

        折扣应用组
      - `icon` string

        图标
      - `is_free_gift` boolean

        该商品列表是否为免费赠品
      - `is_need_split` boolean

        是否允许拆分
      - `subtype` string

        营销活动子类型（取值见 discount\_applications 表）
      - `target_selection` string

        优惠目标选择方式
      - `target_type` string

        优惠作用目标（取值见 discount\_applications 表）
      - `title` string

        优惠名称
      - `total_discount_amount` string

        总折扣金额
      - `type` string

        营销活动类型（取值见 discount\_applications 表）
      - `value` string

        优惠值
      - `value_type` string

        优惠值类型
      *   \]
    - `discount_total` string

      折扣总额
    - `final_line_price` string

      最终行价格
    - `final_price` string

      最终单价
    - `fixed_discount_total` string

      固定折扣总额
    - `id` string

      购物车商品项 ID
    - `image` object

      商品图片链接
    - `image.height` integer

      图片高度
    - `image.path` string

      图片路径
    - `image.src` string

      图片 URL
    - `image.width` integer

      图片宽度
    - `inventory_policy` string

      库存策略（continue 缺货继续销售 / deny 缺货停止销售 / auto\_unpublished 缺货自动下架）
    - `inventory_quantity` integer

      库存数量
    - `inventory_tracking` boolean

      是否启用库存追踪
    - `item_id` string

      商品项 ID
    - `line_price` string

      行价格
    - `mixed_wholesale` boolean

      是否支持混批
    - `options` object[]

      商品款式属性列表

      *   Array \[

      - `name` string

        款式选项名称
      - `value` string

        选项值
      *   \]
    - `origin_price` string

      原价
    - `original_line_price` number

      原始行价格
    - `parts_price` string

      部件价格
    - `price` string

      商品售价-单价
    - `product_handle` string

      商品 Handle
    - `product_id` string

      商品 ID
    - `product_tags` undefined[]

      商品标签
    - `product_title` string

      商品标题
    - `product_type` string

      商品类型
    - `product_url` string

      商品链接
    - `properties` string

      商品款式属性（键值对）
    - `published` boolean

      商品是否已发布（上架）
    - `published_at` string

      商品发布时间
    - `quantity` string

      购买数量
    - `requires_shipping` boolean

      是否需要物流
    - `retail_price` string

      零售价
    - `saved_price` integer

      节省金额
    - `sku` string

      子款式 SKU
    - `taxable` boolean

      是否需要纳税
    - `trunk_price` string

      主干价格
    - `variant_id` string

      子款式 ID
    - `variant_title` string

      子款式标题
    - `vendor` string

      供应商
    - `weight` string

      商品重量
    - `weight_unit` string

      重量单位
    - `wholesale_price` object[]

      批发价（列表）

      *   Array \[

      - `min_quantity` integer

        最小数量
      - `price` string

        价格
      *   \]
    *   \]
  - `total_discount` string

    购物车优惠总价
  - `total_price` string

    购物车商品总金额
  - `updated_at` string

    购物车更新时间
  - `user_id` string

    用户 ID
  - `user_sign` string

    用户签名（游客标识）

```json
{
  "cart": {
    "created_at": "string",
    "currency_code": "string",
    "discount_applications": [
      {
        "apply_method": "string",
        "code": "string",
        "discount_amount": 0,
        "discount_id": "string",
        "discount_message": "string",
        "discount_text": "string",
        "discount_type": "string",
        "entitled_product_list": [
          null
        ],
        "extents": {},
        "extents.application_time": "string",
        "extents.business_custom_data": "string",
        "extents.discount_apply_type": "string",
        "extents.discount_code": "string",
        "extents.discount_rule_info": "string",
        "extents.old_discount_id": "string",
        "extents.use_with_other": "string",
        "icon": "string",
        "is_free_gift": true,
        "message": "string",
        "properties": "string",
        "status": "string",
        "subtype": "string",
        "target_selection": "string",
        "target_type": "string",
        "title": "string",
        "type": "string",
        "value_type": "string"
      }
    ],
    "extra": {
      "client_id": "string"
    },
    "item_count": 0,
    "line_items": [
      {
        "add_quantity": "string",
        "available": true,
        "available_quantity": 0,
        "can_buy": true,
        "compare_at_price": "string",
        "cost_price": "string",
        "custom": true,
        "discount_applications": [
          {
            "allocation_method": "string",
            "code": "string",
            "discount_amount": "string",
            "discount_id": "string",
            "discount_quantity": 0,
            "discount_text": "string",
            "discount_type": "string",
            "extents": {},
            "extents.business_custom_data": "string",
            "extents.old_discount_id": "string",
            "extents.raw_input_line_item_price": "string",
            "groups": [
              null
            ],
            "icon": "string",
            "is_free_gift": true,
            "is_need_split": true,
            "subtype": "string",
            "target_selection": "string",
            "target_type": "string",
            "title": "string",
            "total_discount_amount": "string",
            "type": "string",
            "value": "string",
            "value_type": "string"
          }
        ],
        "discount_total": "string",
        "final_line_price": "string",
        "final_price": "string",
        "fixed_discount_total": "string",
        "id": "string",
        "image": {},
        "image.height": 0,
        "image.path": "string",
        "image.src": "string",
        "image.width": 0,
        "inventory_policy": "string",
        "inventory_quantity": 0,
        "inventory_tracking": true,
        "item_id": "string",
        "line_price": "string",
        "mixed_wholesale": true,
        "options": [
          {
            "name": "string",
            "value": "string"
          }
        ],
        "origin_price": "string",
        "original_line_price": 0,
        "parts_price": "string",
        "price": "string",
        "product_handle": "string",
        "product_id": "string",
        "product_tags": [
          null
        ],
        "product_title": "string",
        "product_type": "string",
        "product_url": "string",
        "properties": "string",
        "published": true,
        "published_at": "string",
        "quantity": "string",
        "requires_shipping": true,
        "retail_price": "string",
        "saved_price": 0,
        "sku": "string",
        "taxable": true,
        "trunk_price": "string",
        "variant_id": "string",
        "variant_title": "string",
        "vendor": "string",
        "weight": "string",
        "weight_unit": "string",
        "wholesale_price": [
          {
            "min_quantity": 0,
            "price": "string"
          }
        ]
      }
    ],
    "total_discount": "string",
    "total_price": "string",
    "updated_at": "string",
    "user_id": "string",
    "user_sign": "string"
  }
}
```
