Create order interface

Create a user shopping order, supporting single product or multiple product ordering, can specify shipping address, coupons and other information.

Points to note

  • The API uses the POST method and requires data to be submitted in application/ format
  • Access requires user login
  • The order status is pending payment, waiting for user payment
  • You can create an order by product ID or product detail list
  • Support using coupons and specified delivery address

Request address

{域名地址}/api/order/create

Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/order/create

Request Syntax

POST {域名地址}/api/order/create
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, can be used when placing an order for a single product
quantity int No Product quantity, can be used when placing an order for a single product
goods_sku_id int No SKU ID, use for placing an order for a single item
details object[] No Multiple product information, either goods_id or details must be provided
remark string No Order remarks
type string No Order type, goods, vip
coupon_code string No Coupon code
coupon_code_id int No Coupon code ID
coupon_id int No Coupon ID, discount coupons
address object No Shipping address information
cart_ids int[] No List of shopping cart IDs

Details item parameters

Field name Type Required Description
goods_id int Product ID
goods_sku_id int SKU ID
quantity int Product Quantity
sku_values array List of SKU options
price int Product Price
total price int item subtotal

Address parameters

Field name Type Required Description
id int No Address ID
name string Is Recipient
phone string Is Contact phone number
Province string Is Province
City string Is City
Country string Is district
address information string Is detailed address
postal code string Is postcode

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 Order Information

Data result parameter

Field name Type Description
id int Order ID
order_id string Order Number
payment_id string Payment流水ID
user_id int User ID
remark string Order remarks
type string Order Type
original amount int Order Original Total Price
amount int Total Actual Order Amount
Paid Time int Payment Time
End Time int Estimated Auto Completion Time
deliver_time int Delivery Time
Finished Time int Order Completion Time
Discount amount int Discount Amount
seller_id int seller ID
seller amount int seller's earnings
share user ID int Promoter ID
share_parent_user_id int Promoter's superior ID
Share amount int Promoter's earnings
share_parent_amount int incomes_of_promoter_s_upline
express_company string express_company
tracking number string express delivery waybill number
created_time int order timestamp
updated_time int update timestamp
status int Order status: -1 Cancelled, 0 Pending payment, 1 Paid, 2 Shipped, 3 Completed, 8 Refunding, 9 Refunded
refund_status int Refund status: -1 Refund failed, 0 No refund or in progress, 1 Refunded
order_address object order delivery address
custom_form_url string Custom form link, it will return this field when the order needs to collect user information

Usage Example

Request example (single product, no SKU)

POST /api/order/create HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json

{
  "goods_id": 188,
  "quantity": 1,
  "type": "goods",
  "remark": "普通商品订单"
}

Example Request (multiple products)

POST /api/order/create HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json

{
  "details": [
    {
      "goods_id": 1,
      "quantity": 2,
      "goods_sku_id": 1,
      "sku_values": [
        {
            "id": 156,
            "archive_id": 32,
            "option_id": 33,
            "title": "Small",
            "option_title": "Size"
        }
      ]
    },
    {
      "goods_id": 2,
      "quantity": 1,
      "goods_sku_id": 3,
      "sku_values": [
        {
            "id": 153,
            "archive_id": 32,
            "option_id": 32,
            "title": "Denim",
            "option_title": "Fiber"
        },
        {
            "id": 156,
            "archive_id": 32,
            "option_id": 33,
            "title": "Small",
            "option_title": "Size"
        }
      ]
    }
  ],
  "type": "goods",
  "address": {
    "name": "王先生",
    "phone": "13888888888",
    "province": "河南省",
    "city": "郑州市",
    "country": "中原区",
    "address_info": "中原西路233号",
    "postcode": "450000"
  },
  "remark": "多商品订单",
  "coupon_code": "COUPON2023"
}

Response Example

{
  "code": 0,
  "msg": "",
  "data": {
    "id": 46,
    "created_time": 1669212548,
    "updated_time": 1669212548,
    "order_id": "202211232209080046",
    "payment_id": "",
    "user_id": 1000,
    "address_id": 0,
    "remark": "普通商品订单",
    "type": "goods",
    "status": 0,
    "refund_status": 0,
    "origin_amount": 9900,
    "amount": 9900,
    "paid_time": 0,
    "end_time": 0,
    "deliver_time": 0,
    "finished_time": 0,
    "discount_amount": 0,
    "seller_id": 15,
    "seller_amount": 7920,
    "share_user_id": 0,
    "share_parent_user_id": 0,
    "share_amount": 0,
    "share_parent_amount": 0,
    "express_company": "",
    "tracking_number": ""
  }
}

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