Get product settlement information, supporting settlement of orders for a single product or multiple products, including discount calculation, address information, etc.
Points to note
- The API uses the POST method and requires data to be submitted in application/ format
- Supports placing an order for a single item (via goods_id, quantity, goods_sku_id parameters) or for multiple items (via details parameters)
- Support using coupons (coupon code or coupon ID)
- User login verification required
- Support setting recipient address and order notes
Request address
{域名地址}/api/order/checkout
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/order/checkout
Request Syntax
POST {域名地址}/api/order/checkout
Content-Type: application/json
Request Headers
This interface also involves common request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
| Field name | Type | Required | Description |
|---|---|---|---|
| goods_id | int | No | Product ID, used when placing an order for a single item, either with the details parameter or not |
| quantity | int | No | Quantity of product, used when placing an order for a single item |
| goods_sku_id | int | No | SKU ID, used when placing an order for a single item |
| details | object[] | No | Array of multiple product information, either with goods_id parameter |
| remark | string | No | Order remarks |
| type | string | No | Order type, such as goods (product), vip (member) |
| coupon_code | string | No | Coupon code |
| coupon_code_id | int | No | Coupon code ID |
| coupon_id | int | No | Coupon ID (discount type coupon) |
| address | object | No | Shipping address information |
Response header
This interface only involves public response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field name | Type | Description |
|---|---|---|
| code | int | Error code |
| msg | string | Error description |
| data | object | Result content object |
Data result parameter
| Field name | Type | Description |
|---|---|---|
| currency code | string | Currency Symbol |
| currency symbol | string | Currency Name |
| details | object[] | product information list |
| original amount | int | total amount before product discount |
| amount | int | Total amount after discount |
| Discount amount | int | Total discount amount |
| coupon_id | int | Coupon ID |
| coupon_code | string | Coupon code |
| coupon_code_id | int | Coupon code ID |
| address_id | int | Recipient Address ID |
| remark | string | Order remarks |
Product information parameters
Each product object includes the following fields (specific fields depend on system design):
| Field name | Type | Description |
|---|---|---|
| id | int | Product Details ID |
| goods_id | int | Product ID |
| goods_sku_id | int | SKU ID |
| quantity | int | Product Quantity |
| price | int | Product Price |
| total price | int | item subtotal |
Usage Example
example request (single item order)
POST /api/order/checkout HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"goods_id": 1,
"quantity": 2,
"goods_sku_id": 1,
"remark": "请尽快发货",
"type": "goods",
"coupon_code": "SAVE100",
"address": {
"name": "张三",
"phone": "13800138000",
"province": "广东省",
"city": "深圳市",
"district": "南山区",
"address": "科技园南区1号",
"zipcode": "518000"
}
}
example request (multiple items order)
POST /api/order/checkout HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"details": [
{
"goods_id": 1,
"quantity": 2,
"goods_sku_id": 1
},
{
"goods_id": 2,
"quantity": 1,
"goods_sku_id": 3
}
],
"remark": "多个商品订单",
"type": "goods",
"coupon_id": 5,
"address": {
"name": "李四",
"phone": "13900139000",
"province": "北京市",
"city": "北京市",
"district": "朝阳区",
"address": "建国路1号",
"zipcode": "100000"
}
}
Response Example
{
"code": 0,
"msg": "获取成功",
"data": {
"currency_code": "CNY",
"currency_symbol": "¥",
"details": [
{
"id": 1,
"goods_id": 1,
"goods_sku_id": 1,
"quantity": 2,
"price": 10000,
"total_price": 20000
}
],
"origin_amount": 20000,
"amount": 18000,
"discount_amount": 2000,
"coupon_id": 0,
"coupon_code": "SAVE100",
"coupon_code_id": 1,
"address_id": 123,
"remark": "请尽快发货"
}
}
error code
| Error code | Description |
|---|---|
| 0 | OK |
| -1 | Error, the reason is indicated in msg |
| 1001 | Not logged in |
| 1002 | Not authorized |
| 200 | API request OK |