Add to shopping cart interface

Add specified products to the shopping cart, supporting information such as product SKU, quantity, etc., suitable for shopping cart operations in e-commerce functions.

Precautions

  • This interface uses the POST method and requires data to be submitted in application/ format
  • Supports logged-in users and non-logged-in users (identified by cart token)
  • Must specify product ID and quantity
  • You can specify the specific product specifications 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:{域名地址}Need to replace it with your domain address, such ashttps://en.anqicms.com/api/cart/add

Request syntax

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

Request header

Field Name Type Required Description
cart string No When not logged in, use this token as user identification

This interface also involves common request headers. For more information, please seeCommon Request Headers (Common Request Headers).

Request Parameters

| Field Name | Type | Required| Description |

archive_id integer Yes
sku_id integer No
quantity integer Yes
status integer No
priority integer No
order_extra object

Response Headers

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 integer Error code
message string Error Description

Example Usage

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 Unauthorized
200 API request OK