---
title: "设置商品数量"
description: >
  订单编辑-设置商品数量接口，编辑订单为一组组合接口(开始编辑，修改商品数量，增加普通商品行，增加自定义商品行，增加商品行折扣，移除商品行折扣，订单编辑提交)，需要调用编辑订单-开始接口，开启一次编辑，如果该接口调用有错误，会在返回值user_errors字段中拿到错误，调用方可以根据是否有错误进行编辑重试（注意：重试需要从order_edit_begin.json订单编辑开始接口开始进行整套编辑订单接口重新调用，重试需要控制次数）
doc_type: openapi
doc_category: openapi
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/order/edit-order-combination-interface/set-item-quantity'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/order/edit-order-combination-interface/set-item-quantity.md'
---
# 设置商品数量

订单编辑-设置商品数量接口，编辑订单为一组组合接口(开始编辑，修改商品数量，增加普通商品行，增加自定义商品行，增加商品行折扣，移除商品行折扣，订单编辑提交)，需要调用编辑订单-开始接口，开启一次编辑，如果该接口调用有错误，会在返回值user_errors字段中拿到错误，调用方可以根据是否有错误进行编辑重试（注意：重试需要从order_edit_begin.json订单编辑开始接口开始进行整套编辑订单接口重新调用，重试需要控制次数）	


- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **Required Scopes:** `write_orders`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
POST /orders/order_edit_set_quantity.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。

## Required Permissions

* `write_orders`

## Request

### Request Headers

* `Content-Type`

  string (required)

  字段值固定为 `application/json; charset=utf-8`。

* `Authorization`

  string (required)

  资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。

### Request Body

* `request`

  object

  请求体

  * `quantity`

    integer

    数量

  * `restock`

    boolean

    是否回退库存

  * `id`

    string

    修改草稿单id，可以从调用订单编辑-开始接口返回参数中获取

  * `line_item_id`

    string

    商品行id

## Response

### Status Codes

* `200`

  更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。

### Response Body

#### 200

* `calculated_line_item`

  object

  本次编辑的商品信息

  * `title`

    string

    商品标题

  * `variant_id`

    string

    商品sku

  * `added_discount_staged_change`

    object

    商品行自定义折扣信息

    * `id`

      string

      折扣id

    * `percent_value`

      string

      百分比的优惠值，0~1之间小数点两位，如0.2=20%off 当折扣是百分比类型，此项有值

    * `description`

      string

      折扣描述

    * `fixed_value`

      object

      固定金额的优惠值，支持两位小数 当折扣是固定金额类型，此项有值

      * `amount`

        string

        金额，两位精度double类型字符串

      * `currency_code`

        string

        币种

  * `id`

    string

    订单编辑草稿单里的商品行id

  * `original_unit_price_set`

    object

    原价，没有应用的优惠价格

    * `presentment_money`

      object

      市场币种金额信息

      * `amount`

        string

        金额值，2位精度字符串

      * `currency_code`

        string

        币种

    * `shop_money`

      object

      店铺币种金额信息

      * `amount`

        string

        金额值，2位精度字符串

      * `currency_code`

        string

        币种

  * `quantity`

    string

    数量

  * `required_shipping`

    boolean

    是否需要发货

  * `taxable`

    boolean

    是否需要计税

* `calculated_order`

  object

  编辑订单草稿单信息

  * `committed`

    boolean

    是否已经提交保存到订单

  * `id`

    string

    订单编辑草稿单id

* `user_errors`

  array<object>

  本次编辑的错误提示信息，如果执行有错误，会在此字段返回，调用方可根据错误码进行重试(注意：重试需要从order_edit.json订单编辑开始接口开始进行整套编辑订单接口重新调用)

  * `message`

    string

    错误信息

  * `code`

    string

    错误码，如果执行结果有错误，会通过此字段返回错误码，调用方可根据错误码进行重试(注意：重试需要从order_edit.json订单编辑开始接口开始进行整套编辑订单接口重新调用)

  * `field`

    array<string>

    The path to the input field that caused the error. 导致错误的输入字段的路径


#### 401

* `errors`

  string

  错误描述。


#### 429

* `errors`

  string

  错误描述。


## OpenAPI Definition

```json
{
  "description": "订单编辑-设置商品数量接口，编辑订单为一组组合接口(开始编辑，修改商品数量，增加普通商品行，增加自定义商品行，增加商品行折扣，移除商品行折扣，订单编辑提交)，需要调用编辑订单-开始接口，开启一次编辑，如果该接口调用有错误，会在返回值user_errors字段中拿到错误，调用方可以根据是否有错误进行编辑重试（注意：重试需要从order_edit_begin.json订单编辑开始接口开始进行整套编辑订单接口重新调用，重试需要控制次数）\t\n",
  "externalDocs": {
    "description": "接口使用的权限点: `write_orders` ，更多权限点使用信息，请参考:",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=zh-hans-cn",
    "errorTableDescription": ""
  },
  "operationId": "OP7dp6nv",
  "parameters": [
    {
      "name": "Content-Type",
      "in": "header",
      "description": "字段值固定为 `application/json; charset=utf-8`。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": "资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": "资源的访问令牌。请参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "request": {
              "name": "request",
              "description": "请求体",
              "type": "object",
              "properties": {
                "quantity": {
                  "name": "quantity",
                  "description": "数量",
                  "type": "integer",
                  "example": 2
                },
                "restock": {
                  "name": "restock",
                  "description": "是否回退库存",
                  "type": "boolean",
                  "example": false
                },
                "id": {
                  "name": "id",
                  "description": "修改草稿单id，可以从调用订单编辑-开始接口返回参数中获取",
                  "type": "string",
                  "example": "21098923432423423423"
                },
                "line_item_id": {
                  "name": "line_item_id",
                  "description": "商品行id",
                  "type": "string",
                  "example": "1"
                }
              },
              "required": [
                "id",
                "line_item_id",
                "quantity"
              ],
              "example": {
                "line_item_id": "1",
                "quantity": 2,
                "restock": false,
                "id": "21098923432423423423"
              }
            }
          },
          "required": [
            "request"
          ],
          "example": {
            "request": {
              "id": "21098923432423423423",
              "line_item_id": "1",
              "quantity": 2,
              "restock": false
            }
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。",
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "calculated_line_item": {
                "name": "calculated_line_item",
                "description": "本次编辑的商品信息",
                "type": "object",
                "properties": {
                  "title": {
                    "name": "title",
                    "description": "商品标题",
                    "type": "string",
                    "example": "normal item"
                  },
                  "variant_id": {
                    "name": "variant_id",
                    "description": "商品sku",
                    "type": "string",
                    "example": "18057243001210740422372124"
                  },
                  "added_discount_staged_change": {
                    "name": "added_discount_staged_change",
                    "description": "商品行自定义折扣信息",
                    "type": "object",
                    "properties": {
                      "id": {
                        "name": "id",
                        "description": "折扣id",
                        "type": "string",
                        "example": "6068787948765604961"
                      },
                      "percent_value": {
                        "name": "percent_value",
                        "description": "百分比的优惠值，0~1之间小数点两位，如0.2=20%off 当折扣是百分比类型，此项有值",
                        "type": "string",
                        "example": "0"
                      },
                      "description": {
                        "name": "description",
                        "description": "折扣描述",
                        "type": "string",
                        "example": "customized discount"
                      },
                      "fixed_value": {
                        "name": "fixed_value",
                        "description": "固定金额的优惠值，支持两位小数 当折扣是固定金额类型，此项有值",
                        "type": "object",
                        "properties": {
                          "amount": {
                            "name": "amount",
                            "description": "金额，两位精度double类型字符串",
                            "type": "string",
                            "example": "5.99"
                          },
                          "currency_code": {
                            "name": "currency_code",
                            "description": "币种",
                            "type": "string",
                            "example": "USD"
                          }
                        },
                        "example": {
                          "currency_code": "USD",
                          "amount": "5.99"
                        }
                      }
                    },
                    "example": {
                      "fixed_value": {
                        "currency_code": "USD",
                        "amount": "5.99"
                      },
                      "id": "6068787948765604961",
                      "percent_value": "0",
                      "description": "customized discount"
                    }
                  },
                  "id": {
                    "name": "id",
                    "description": "订单编辑草稿单里的商品行id",
                    "type": "string",
                    "example": "6068787943765994592"
                  },
                  "original_unit_price_set": {
                    "name": "original_unit_price_set",
                    "description": "原价，没有应用的优惠价格",
                    "type": "object",
                    "properties": {
                      "presentment_money": {
                        "name": "presentment_money",
                        "description": "市场币种金额信息",
                        "type": "object",
                        "properties": {
                          "amount": {
                            "name": "amount",
                            "description": "金额值，2位精度字符串",
                            "type": "string",
                            "example": "10.0"
                          },
                          "currency_code": {
                            "name": "currency_code",
                            "description": "币种",
                            "type": "string",
                            "example": "USD"
                          }
                        },
                        "example": {
                          "amount": "10.0",
                          "currency_code": "USD"
                        }
                      },
                      "shop_money": {
                        "name": "shop_money",
                        "description": "店铺币种金额信息",
                        "type": "object",
                        "properties": {
                          "amount": {
                            "name": "amount",
                            "description": "金额值，2位精度字符串",
                            "type": "string",
                            "example": "10.0"
                          },
                          "currency_code": {
                            "name": "currency_code",
                            "description": "币种",
                            "type": "string",
                            "example": "USD"
                          }
                        },
                        "example": {
                          "amount": "10.0",
                          "currency_code": "USD"
                        }
                      }
                    },
                    "example": {
                      "presentment_money": {
                        "amount": "10.0",
                        "currency_code": "USD"
                      },
                      "shop_money": {
                        "amount": "10.0",
                        "currency_code": "USD"
                      }
                    }
                  },
                  "quantity": {
                    "name": "quantity",
                    "description": "数量",
                    "type": "string",
                    "example": "1"
                  },
                  "required_shipping": {
                    "name": "required_shipping",
                    "description": "是否需要发货",
                    "type": "boolean",
                    "example": true
                  },
                  "taxable": {
                    "name": "taxable",
                    "description": "是否需要计税",
                    "type": "boolean",
                    "example": true
                  }
                },
                "example": {
                  "title": "normal item",
                  "variant_id": "18057243001210740422372124",
                  "added_discount_staged_change": {
                    "id": "6068787948765604961",
                    "percent_value": "0",
                    "description": "customized discount",
                    "fixed_value": {
                      "currency_code": "USD",
                      "amount": "5.99"
                    }
                  },
                  "id": "6068787943765994592",
                  "original_unit_price_set": {
                    "presentment_money": {
                      "currency_code": "USD",
                      "amount": "10.0"
                    },
                    "shop_money": {
                      "currency_code": "USD",
                      "amount": "10.0"
                    }
                  },
                  "quantity": "1",
                  "required_shipping": true,
                  "taxable": true
                }
              },
              "calculated_order": {
                "name": "calculated_order",
                "description": "编辑订单草稿单信息",
                "type": "object",
                "properties": {
                  "committed": {
                    "name": "committed",
                    "description": "是否已经提交保存到订单",
                    "type": "boolean",
                    "example": true
                  },
                  "id": {
                    "name": "id",
                    "description": "订单编辑草稿单id",
                    "type": "string",
                    "example": "2106068787725276328168095160459272"
                  }
                },
                "example": {
                  "committed": true,
                  "id": "2106068787725276328168095160459272"
                }
              },
              "user_errors": {
                "name": "user_errors",
                "description": "本次编辑的错误提示信息，如果执行有错误，会在此字段返回，调用方可根据错误码进行重试(注意：重试需要从order_edit.json订单编辑开始接口开始进行整套编辑订单接口重新调用)",
                "type": "array",
                "items": {
                  "name": "user_errors",
                  "description": "本次编辑的错误提示信息，如果执行有错误，会在此字段返回，调用方可根据错误码进行重试(注意：重试需要从order_edit.json订单编辑开始接口开始进行整套编辑订单接口重新调用)",
                  "type": "object",
                  "properties": {
                    "message": {
                      "name": "message",
                      "description": "错误信息",
                      "type": "string",
                      "example": "param is null"
                    },
                    "code": {
                      "name": "code",
                      "description": "错误码，如果执行结果有错误，会通过此字段返回错误码，调用方可根据错误码进行重试(注意：重试需要从order_edit.json订单编辑开始接口开始进行整套编辑订单接口重新调用)",
                      "type": "string",
                      "example": "UNAUTHORIZED_ACCESS"
                    },
                    "field": {
                      "name": "field",
                      "description": "The path to the input field that caused the error. 导致错误的输入字段的路径",
                      "type": "array",
                      "items": {
                        "name": "field",
                        "description": "The path to the input field that caused the error. 导致错误的输入字段的路径",
                        "type": "string",
                        "example": "[\"id\"]"
                      },
                      "example": [
                        "[\"id\"]"
                      ]
                    }
                  },
                  "example": {
                    "code": "UNAUTHORIZED_ACCESS",
                    "field": [
                      "[\"id\"]"
                    ],
                    "message": "param is null"
                  }
                },
                "example": [
                  {
                    "code": "UNAUTHORIZED_ACCESS",
                    "field": [
                      "[\"id\"]"
                    ],
                    "message": "param is null"
                  }
                ]
              }
            },
            "example": {
              "calculated_line_item": {
                "original_unit_price_set": {
                  "presentment_money": {
                    "amount": "10.0",
                    "currency_code": "USD"
                  },
                  "shop_money": {
                    "amount": "10.0",
                    "currency_code": "USD"
                  }
                },
                "quantity": "1",
                "required_shipping": true,
                "taxable": true,
                "title": "normal item",
                "variant_id": "18057243001210740422372124",
                "added_discount_staged_change": {
                  "description": "customized discount",
                  "fixed_value": {
                    "amount": "5.99",
                    "currency_code": "USD"
                  },
                  "id": "6068787948765604961",
                  "percent_value": "0"
                },
                "id": "6068787943765994592"
              },
              "calculated_order": {
                "id": "2106068787725276328168095160459272",
                "committed": true
              },
              "user_errors": [
                {
                  "field": [
                    "[\"id\"]"
                  ],
                  "message": "param is null",
                  "code": "UNAUTHORIZED_ACCESS"
                }
              ]
            }
          }
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "post",
  "path": "/orders/order_edit_set_quantity.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。"
        }
      }
    }
  ],
  "info": {
    "title": "设置商品数量",
    "version": "v20270301"
  },
  "authIndexes": [
    "write_orders"
  ]
}
```