Adjust the number of items
The shopping cart ajax API is used for the shopping cart interaction generated by the customer during the session. This interface can be called when the number of items in the shopping cart needs to be updated.
Request information
API Path:
POST https://{handle}.myshopline.com/api/cart/change
Request header:
| Parameter name | Parameter type | Required or not | 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: \*/\*:
application/json:
|
Request body:
| Parameter name | Parameter type | Required | Array or not | Example | describe |
|---|---|---|---|---|---|
| id | String | N | N | 36110175633573 | The unique identification of the product is SKU_ id |
| line | Integer | N | N | 1 | The 1-based index position of the item in the cart |
| 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 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 |
Response information
Response body:
| Parameter name | Parameter type | Array or not | Example | describe | ||||
|---|---|---|---|---|---|---|---|---|
| token | String | N | 36110175633573 | Shopping cart token | ||||
| note | String | N | Shopping cart notes | Shopping cart notes | ||||
| attributes | Map<String,String> | N | Shopping cart properties | |||||
| original_total_price | Double | N | Total original price of shopping cart goods | |||||
| items_subtotal_price | Double | N | Subtotal of shopping cart goods (discount of business conduct has been deducted) | |||||
| total_price | Double | N | Final pricing of shopping cart (discount of commodity and shopping cart have been deducted) | |||||
| total_discount | Double | N | Total discount amount of shopping cart (commodity line discount + shopping cart level discount) | |||||
| total_weight | Double | N | Total weight of goods | |||||
| item_count | Integer | N | Total quantity of goods in shopping cart | |||||
| requires_shipping | Boolean | N | Whether shipment is required (as long as one item in the shopping cart needs to be shipped) | |||||
| currency | String | N | settlement currency | |||||
| cart_level_discount_applications | Object | Y | Shopping cart level discount information | |||||
| amount | Double | N | Preferential amount | |||||
| discount_application | Object | N | ||||||
| type | Integer | N | ||||||
| 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: | |||||
| target_type | String | N | ||||||
| benefit_type | Integer | N | ||||||
| status | String | N | The application status of the discount code in the 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 | |||||
| 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 | ![]() | |||||
| 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 | ||||||
| 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: | |||||
| target_type | String | N | ||||||
| benefit_type | Integer | N | ||||||
| status | String | N | The application status of the discount code in the 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 | |||||
| gift_card | Object | Y | ||||||
| gift_card_code | String | N | xxxxxxxxxxxxfb3c | Gift card code, the last 4 characters of the gift card | ||||
| gift_card_status | Integer | N | 1 | Gift card status, indicating whether the gift card is available,1=available,0=unavailable | ||||
| gift_card_allocated_amount | String | N | 10.00 USD | The amount of gift card deduction in the current shopping cart (currency is the current market settlement currency) | ||||
| error_message | String | N | This gift card has reached its usage date. | Gift card application error message | ||||
| gift_card_use_in_cart | Boolean | N | 1 | Whether the shopping cart uses a gift card to check out,1=yes,0=no |
Request and response example
Scenario 1: Update the shopping cart normally
{
"token": "a5f1d38bf17f4578959ad0d8e4ff7cac",
"note": "Shopping cart notes",
"attributes": {},
"currency": "USD",
"original_total_price": 110,
"items_subtotal_price": 101,
"total_price": 11,
"total_discount": 99,
"total_weight": 0,
"item_count": 11,
"requires_shipping": true,
"cart_level_discount_applications": [
{
"amount": 90,
"discount_application": {
"type": 1,
"title": "90 off on all items over 100",
"description": null,
"value": 90,
"created_at": null,
"value_type": "fix_amount",
"target_type": "line_item",
"status": "enable",
"error_code": null,
"error_message": null
}
}
],
"items": [
{
"id": "18053690554475963802050412",
"properties": null,
"quantity": 10,
"title": "Custom products",
"price": 10,
"discounts": [],
"sku": "18053690554475963802050412",
"grams": "0.0",
"taxable": true,
"url": "https://{handle}/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://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"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://{handle}//products/promotional_items",
"image": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
"handle": "promotional items",
"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 items",
"variant_title": "",
"variant_options": [],
"options_with_values": [],
"line_level_discount_allocations": [
{
"amount": 9,
"discount_application": {
"type": 8,
"title": "Promotions",
"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
}
],
"gift_card_enable_cart": true,
"gift_card": [
{
"gift_card_code": "************4501",
"gift_card_status": 1,
"gift_card_allocated_amount": "10.00",
"error_message": null
}
]
}
Scenario 2: Request Error:
POST https://{handle}.myshopline.com/api/cart/change
status:404
{
"message": "error code",
"description": "error description"
}
Was this article helpful to you?
