Add to cart

The shopping cart API is used for the shopping cart interaction generated by the customer during the session. When a new item needs to be added to the shopping cart, the corresponding operation can be completed by requesting this interface.

Request information

API Path:

POST https://{handle}.myshopline.com/cart/add

Request header:

Parameter name

Parameter type

Required

Array or not

Default value

describe

Content-Type

String

Y

N

application/json

Accept

String

N

N

*/*

The response will return different content-type and status codes based on the request type. The corresponding enumeration values are as follows:

  1. \*/\*
  • Response Content-type: text/html; charset=utf-8

  • Status code: 302 , Redirect to the shopping cart page by default.

  1. application/json:
  • Response Content-type: application/json; charset=utf-8

  • Status code: 200

request body:

Parameter name

Parameter name

Parameter type

Required

Array or not

Example

describe

items

Object[]

Y

Y

Shopping cart item list

id

String

Y

N

36110175633573

The unique identification of the product is SKU_ id

quantity

Long

Y

N

2

The number of items added, the number of items in the shopping cart after adding = the original number + the number added this time

groupId

String

N

N

0

Item group ID, you do not need to fill in when adding a product that does not exist in the shopping cart

  1. When adding the same product to the shopping cart and the row is split due to different attribute groups, you need to pass in the groupId to correspond

properties

Object

N

Y

image.png
  1. Name(required): User-defined attribute name

  2. Value: custom attribute value

  3. Type(required): type, attribute enumeration has three types: text, picture and link, text: character, display type is name: value; Picture: picture, display type is name: get and render thumbnail through urls, click the pop-up to display the thumbnail, and support download; Link: hyperlink, display type is name: value, support clicking to jump to the first url

  4. Show: Whether to display at the front desk

  5. ExtInfo: extended field

Response information

Response body:

Parameter name

Parameter name

Parameter name

Parameter name

Parameter type

Array or not

Example

describe

items

Object[]

Y

Shopping cart item list

id

String

N

36110175633573

The unique identification of the product is SKU_ id

group_id

String

N

0

Item group ID

quantity

Integer

N

2

Quantity of goods

properties

Long

N

image.png
  1. Name: User-defined attribute name

  2. Value: custom attribute value

  3. Type: type, attribute enumeration has three types: text, picture and link, text: character, display type is name: value; Picture: picture, display type is name: get and render thumbnail through urls, click the pop-up to display the thumbnail, and support download; Link: hyperlink, display type is name: value, support clicking to jump to the first url

  4. Show: Whether to display at the front desk

  5. ExtInfo: extended field

variant_id

String

N

36110175633573

Item SKU_ id

title

String

N

test1

Product title + SKU title name + specification

price

Double

N

200

Commodity price

original_price

Double

N

200

Original price of goods (may be 0)

discounted_price

Double

N

200

Price after discount

line_price

Double

N

200

Commodity line selling price

original_line_price

Double

N

200

Original price of commodity line (may be 0)

total_discount

Double

N

200

Total discount amount of a single item

discounts

Object

Y

Discount of commodity bank

amount

Double

N

200

Preferential amount

title

String

N

50 minus 100

Preferential name

sku

String

N

Red XL

Item SKU_ id

grams

String

N

100

Commodity weight unit: G

taxable

Boolean

N

true

Whether to collect tax

product_id

String

N

36110175633573

Commodity SPU_ id

gift_card

Boolean

N

true

Is it a gift card product

final_price

Double

N

500

Amount of goods involved in pricing

final_line_price

Double

N

500

Amount of commodity line participating in pricing

url

String

N

https://ddfasdfasdf

Commodity master link

featured_image

String

N

aspectRatio

Double

N

Aspect ratio

alt

String

N

Mouse over prompt

height

Integer

N

Display height

url

String

N

picture

width

Integer

N

Display width

image

String

N

Product image

handle

String

N

Product handle

requires_shipping

String

N

Whether shipment is required

product_title

String

N

Product title

variant_title

String

N

Splicing of all specifications

variant_options

String

N

Enumeration of all specifications

options_with_values

String

N

Specifications

name

String

N

Specifications name

value

String

N

Specifications value

line_level_discount_allocations

String

N

Discount of commodity bank information

amount

Double

N

Preferential amount

discountApplication

String

N

type

Integer

N

The type of promotion applied to the product line.

0:RD_ACTIVITY,

1:TIME_LIMITED_ACTIVITY,

2:BUNDLED_ACTIVITY,

3:DISCOUNT_CODE,

4:ONE_SHOP_GROUP,

5:GIFT_ACTIVITY,

6:PRE_ORDER_ACTIVITY,

7:ADD_ONS_ACTIVITY,

8:GIFT_BOX,

9:UPSELL_PRODUCT

title

String

N

Preferential name

description

String

N

Offer describe

value

Double

N

Preferential amount

created_at

String

N

Activity creation time

value_type

String

N

Discount activity type:

  1. Percentage discount

  2. fix_ Amount fixed amount

target_type

String

N

  1. Preferential target

  2. line_ Item item

  3. shipping_ Line freight

benefit_type

Integer

N

The type of discount applied to the product line.

-1:No discount

1:Amount reduction

2:Discount

3:Free shipping fee

4:Marked-up item

5:Preferential price for any N items

6:Preferential price for the combination of A and B

7:Gift

8:Fixed selling price

9:The lowest-priced item is free

11:Discount for the Nth item

12:Buy x and get y free

13:Customized

14:M (Monetary Unit) for N Items

status

String

N

The application status of the discount code in the shopping cart:

  • enable: Cannot be applied in the current shopping cart

  • unable: Can be applied in the current shopping cart

error_code

String

N

An error code will be returned when the discount code cannot be applied

error_message

String

N

An error message will be returned when the discount code cannot be applied

line_level_total_discount

Double

N

Total amount of commodity bank

Request and response example

Scenario 1: Update the shopping cart normally

{
"items": [
{
"id": "18053690554475963802050412",
"properties": null,
"quantity": 10,
"title": "Custom products",
"price": 10,
"discounts": [],
"sku": "18053690554475963802050412",
"grams": "0.0",
"taxable": true,
"url": "https://hello.myshopline.com/products/Custom_products",
"image": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"handle": "Custom_products",
"group_id": "0",
"variant_id": "18053690554475963802050412",
"original_price": 0,
"discounted_price": 10,
"line_price": 100,
"original_line_price": 0,
"total_discount": 0,
"product_id": "16053690554473111675530412",
"gift_card": false,
"final_price": 10,
"final_line_price": 100,
"featured_image": {
"alt": null,
"height": null,
"url": "https://test001.myshopline.com/products/promotional_items",
"width": null,
"aspect_ratio": null
},
"requires_shipping": true,
"product_title": "Custom_products",
"variant_title": "",
"variant_options": [],
"options_with_values": [],
"line_level_discount_allocations": [],
"line_level_total_discount": 0
},
{
"id": "18053340946130027787140412",
"properties": null,
"quantity": 1,
"title": "promotional items",
"price": 10,
"discounts": [
{
"amount": 9,
"title": "Promotions"
}
],
"sku": "18053340946130027787140412",
"grams": "0.0",
"taxable": true,
"url": "https://test001.myshopline.com/products/promotional_items",
"image": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"handle": "promotional",
"group_id": "0",
"variant_id": "18053340946130027787140412",
"original_price": 0,
"discounted_price": 1,
"line_price": 10,
"original_line_price": 0,
"total_discount": 9,
"product_id": "16053340946118954823760412",
"gift_card": false,
"final_price": 1,
"final_line_price": 1,
"featured_image": {
"alt": null,
"height": null,
"url": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"width": null,
"aspect_ratio": null
},
"requires_shipping": true,
"product_title": "promotional",
"variant_title": "",
"variant_options": [],
"options_with_values": [],
"line_level_discount_allocations": [
{
"amount": 9,
"discount_application": {
"type": 8,
"title": "promotional",
"description": null,
"value": 9,
"created_at": null,
"value_type": null,
"target_type": "line_item",
"status": "enable",
"error_code": null,
"error_message": null
}
}
],
"line_level_total_discount": 9
}
]
}

Scenario 2: The shopping cart does not exist:

POST https://{handle}.myshopline.com/cart/add

status:404 
{
"message": "error code",
"description": "error description"
}
Was this article helpful to you?