Add shopping cart interface

Add the specified product to the shopping cart, supporting specified product SKU, quantity, and other information, suitable for shopping cart operations in e-commerce functions.

Points to note

  • The API uses the POST method and requires data to be submitted in application/ format
  • Supports logged-in users and anonymous users (identified through cart token)
  • The product ID and quantity must be specified.
  • Specify the specific product specification by SKU ID
  • If the product is already in the shopping cart, the quantity will be updated instead of adding a new one

Request address

{域名地址}/api/cart/add

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

Request Syntax

POST {域名地址}/api/cart/add
Content-Type: application/json

Request Headers

Field name Type Required Description
cart string No Use this token as user identification when not logged in

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 |

archive_id int Is
sku_id int No
quantity int Is
status int No
priority int No
order_extra object

Response header

This interface only involves common 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

Usage Example

Request example

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

{
  "archive_id": 1,
  "sku_id": 1,
  "quantity": 2,
  "order_extra": {
    "gift_wrapping": true,
    "message": "生日快乐"
  }
}

Response Example

{
  "code": 0,
  "msg": "保存成功"
}

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