# 按购物车ID向购物车添加商品

按购物车ID向购物车添加商品。如果购物车中已有具有相同SKU的商品，则现有商品将被传入的值替换。

Endpoint: PUT /v2/admin/project/{project_id}/cart/{cart_id}/fill
Version: 2.0.0
Security: basicAuth

## Path parameters:

  - `project_id` (integer, required)
    项目ID。您可以在发布商帐户的项目名称旁找到此参数；使用项目时，也可以在浏览器地址栏中找到此参数。URL格式如下：https://publisher.xsolla.com//projects/。
    Example: 44056

  - `cart_id` (string, required)
    购物车ID。
    Example: "custom_id"

## Query parameters:

  - `locale` (string)
    响应语言。符合ISO 639-1标准的两位小写语言代码（例如en）。name和description等本地化字段支持五字符区域代码（例如en-US），但在响应中会标准化为两位代码。支持的语言完整列表请参阅文档。

## Header parameters:

  - `x-user-for` (string)
    可使用艾克索拉登录管理器用户JWT或支付收银台访问令牌传递用户标识符。
    Example: "ACCESS_TOKEN/LOGIN_JWT"

  - `x-user-id` (string)
    使用购物车销售游戏时可以使用您自己的用户ID。
    Example: "UNIQUE_ID"

## Request fields (application/json):

  - `country` (string)
    符合[ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)标准的两位大写国家/地区代码。关于[艾克索拉支持的国家/地区](https://developers.xsolla.com/zh/doc/shop-builder/references/supported-countries/)的详细信息，请参阅文档。示例：country=US
    Example: "US"

  - `currency` (string)
    购物车中显示的商品价格币种。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准的三字母代码。关于[艾克索拉支持的币种](https://developers.xsolla.com/zh/doc/pay-station/references/supported-currencies/)的详细信息，请参阅文档。
    Example: "USD"

  - `items` (array, required)

  - `items.sku` (string, required)
    唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。
    Example: "t-shirt"

  - `items.quantity` (number, required)
    商品的数量。
    Example: 2

## Response 200 fields (application/json):

  - `cart_id` (string)
    购物车ID。调用购买页面或支付API接口时，请传入该ID。
    Example: "cart_id"

  - `price` (object,null)
    购物车价格。

  - `price.amount` (string)

  - `price.amount_without_discount` (string)

  - `price.currency` (string)

  - `is_free` (boolean)
    如果为true，则购物车为免费。

  - `items` (array)

  - `items.sku` (string)

  - `items.groups` (array)

  - `items.groups.external_id` (string)

  - `items.groups.name` (string)

  - `items.name` (string,null)

  - `items.attributes` (array)
    与商品对应的属性及其值的列表。可用于商品目录筛选。

  - `items.attributes.external_id` (string)
    唯一属性ID。 external_id只能包含大小写英文字母、数字、短横线和下划线。

  - `items.attributes.name` (string)
    属性名称。
    Example: "Genre"

  - `items.attributes.values` (array)

  - `items.attributes.values.external_id` (string)
    属性的唯一值ID。 external_id只能包含小写英文字母、数字、短横线和下划线。

  - `items.attributes.values.value` (string)
    属性值。
    Example: "Strategy"

  - `items.type` (string)

  - `items.description` (string)

  - `items.image_url` (string)

  - `items.quantity` (integer)

  - `items.is_free` (boolean)
    该商品是否免费。

  - `items.is_bonus` (boolean)

  - `items.promotions` (array)
    应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组：

* 为某商品配置了折扣促销活动。

* 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动，则返回空数组。

  - `items.promotions.name` (string)

  - `items.promotions.date_start` (string,null)

  - `items.promotions.date_end` (string,null)

  - `items.promotions.discount` (object,null)

  - `items.promotions.discount.percent` (string,null)

  - `items.promotions.discount.value` (string,null)

  - `items.promotions.bonus` (array)

  - `items.promotions.bonus.sku` (string)

  - `items.promotions.bonus.quantity` (integer)

  - `items.promotions.bonus.type` (string)
    赠品类型。
    Enum: "virtual_good", "virtual_currency", "bundle", "physical_good", "game_key", "nft"

  - `items.promotions.bonus.name` (string)
    赠品名称。不适用于physical_good赠品类型。

  - `items.promotions.bonus.image_url` (string)
    赠品图片URL。不适用于physical_good赠品类型。

  - `items.promotions.bonus.bundle_type` (string)
    赠品捆绑包商品类型。仅适用于bundle赠品类型。
    Enum: "standard", "virtual_currency_package"

  - `items.promotions.limits` (object)

  - `items.promotions.limits.per_user` (object)

  - `items.promotions.limits.per_user.available` (integer)

  - `items.promotions.limits.per_user.total` (integer)

  - `items.can_be_bought` (boolean)
    如为true，则用户可以购买商品。

  - `items.vp_rewards` (array)
    该商品的累充积分奖励列表。

  - `items.vp_rewards.item_id` (integer)
    内部唯一商品ID。

  - `items.vp_rewards.sku` (string)
    唯一累充积分ID。

  - `items.vp_rewards.amount` (integer)
    累充积分数量。

  - `items.vp_rewards.name` (string)
    累充积分名称。

  - `items.vp_rewards.image_url` (string)
    图片URL。

  - `items.vp_rewards.is_clan` (boolean)
    累充积分是否用于公会累充奖励链。

  - `items.loyalty_rewards` (array)
    用户购买商品后获得的忠诚积分奖励。

  - `items.loyalty_rewards.name` (string)
    忠诚积分名称。

  - `items.loyalty_rewards.sku` (string)
    忠诚积分SKU。调用其他API时，请将该值作为loyalty_point_sku参数传入，例如创建使用忠诚积分支付的订单时。

  - `items.loyalty_rewards.description` (string)
    忠诚积分描述。

  - `items.loyalty_rewards.image_url` (string,null)
    图片URL。

  - `items.loyalty_rewards.amount` (integer)
    用户购买商品后获得的忠诚积分数量。

  - `items.limits` (object,null)
    商品限制数。

  - `items.limits.per_user` (object,null)
    单个用户的商品购买数量限制。

  - `items.limits.per_user.total` (integer)
    单个用户可购买的最大商品数量。
    Example: 5

  - `items.limits.per_user.available` (integer)
    当前用户可购买的剩余商品数量。
    Example: 3

  - `items.limits.per_user.recurrent_schedule` (any)

  - `items.limits.per_user.limit_exceeded_visibility` (string)
    设定商品在达到购买限制后、下次限制重置前在商品目录中的可见性。

适用于在recurrent_schedule数组中配置了周期性重置数量限制的商品。

如果未配置重置限制，则达到购买限制后，无论limit_exceeded_visibility的值如何，该商品都不会显示在商品目录中。

可能值：
- show — 达到购买限制后，商品目录检索API调用仍会返回该商品。在客户端侧
商品目录检索API调用中，达到限制后返回的商品会带有can_be_bought: false 标志。下一次重置日期
将在reset_next_date中返回。
- hide — 达到购买限制后，在限制
重置之前，商品目录检索API调用不会返回该商品。
    Enum: "show", "hide"

  - `items.limits.per_item` (object,null)
    单个商品的购买数量限制。

  - `items.limits.per_item.total` (integer)
    所有用户可购买的最大商品数量。
    Example: 5

  - `items.limits.per_item.available` (integer)
    所有用户还可购买的剩余商品数量。
    Example: 3

  - `items.periods` (array,null)
    商品销售期。

  - `items.periods.date_from` (string)
    指定商品开始可购的日期。
    Example: "2020-08-11T10:00:00+03:00"

  - `items.periods.date_until` (string,null)
    指定商品停止可购的日期。可为null。
    Example: "2020-08-11T20:00:00+03:00"

  - `items.price` (object,null)
    商品价格。

  - `items.price.amount` (string)

  - `items.price.amount_without_discount` (string)

  - `items.price.currency` (string)

  - `items.virtual_prices` (array)
    虚拟价格。

  - `items.virtual_prices.amount` (integer)
    以虚拟货币表示的商品价格。
    Example: 100

  - `items.virtual_prices.amount_without_discount` (integer)
    商品折扣前的虚拟货币价格。由于折扣不适用于虚拟货币价格，因此该值始终等于amount。
    Example: 200

  - `items.virtual_prices.sku` (string)
    虚拟货币SKU。
    Example: "vc_gold"

  - `items.virtual_prices.is_default` (boolean)
    是否为默认虚拟货币价格。
    Example: true

  - `items.virtual_prices.image_url` (string,null)
    虚拟货币图片URL。
    Example: "http://image.png"

  - `items.virtual_prices.name` (string)
    虚拟货币名称。
    Example: "Gold"

  - `items.virtual_prices.type` (string)
    商品类型。对于虚拟货币，该值为virtual_currency。
    Example: "virtual_currency"

  - `items.virtual_prices.description` (string,null)
    虚拟货币说明。
    Example: "In-game currency used to purchase weapons and upgrades"

  - `promotions` (array)
    应用于整个购物车的促销活动。仅在以下情况下返回该数组：

* 促销活动影响购物车总金额，例如使用了具有对购买项提供折扣设置的兑换码。

* 促销活动向购物车添加了赠品。

如果未应用任何订单级促销，则返回空数组。

  - `promotions.name` (string)

  - `promotions.date_start` (string,null)

  - `promotions.date_end` (string,null)

  - `promotions.discount` (object,null)

  - `promotions.discount.percent` (string,null)

  - `promotions.discount.value` (string,null)

  - `promotions.bonus` (array)

  - `promotions.bonus.sku` (string)

  - `promotions.bonus.quantity` (integer)

  - `promotions.bonus.type` (string)
    赠品类型。
    Enum: "virtual_good", "virtual_currency", "bundle", "physical_good", "game_key", "nft"

  - `promotions.bonus.name` (string)
    赠品名称。不适用于physical_good赠品类型。

  - `promotions.bonus.image_url` (string)
    赠品图片URL。不适用于physical_good赠品类型。

  - `promotions.bonus.bundle_type` (string)
    赠品捆绑包商品类型。仅适用于bundle赠品类型。
    Enum: "standard", "virtual_currency_package"

  - `promotions.limits` (object)

  - `promotions.limits.per_user` (object)

  - `promotions.limits.per_user.available` (integer)

  - `promotions.limits.per_user.total` (integer)

  - `warnings` (array)

  - `warnings.sku` (string)

  - `warnings.quantity` (integer)

  - `warnings.errorCode` (integer)

  - `warnings.errorMessage` (string)

## Response 401 fields (application/json):

  - `statusCode` (integer)
    Example: 401

  - `errorCode` (integer)
    Example: 1020

  - `errorMessage` (string)
    Example: "[0401-1020]: Error in Authentication method occurred"

## Response 404 fields (application/json):

  - `statusCode` (integer)
    Example: 404

  - `errorCode` (integer)
    Example: 5008

  - `errorMessage` (string)
    Example: "[0401-5008]: Could not find User"

## Response 422 fields (application/json):

  - `errorCode` (integer)
    Example: 1401

  - `statusCode` (integer)
    Example: 422

  - `errorMessage` (string)
    Example: "[0401-1401]: Invalid cart"


