Edit cart products
The shopping cart ajax API is used for the shopping cart interaction generated by the customer during the session. When the number of items in the shopping cart or the custom properties of the item needs to be edited, this API can be called.
Request information
API Path:
POST https://{handle}.myshopline.com/cart/update
Request header:
| Parameter name | Parameter type | Required or not | Array or not | Default value | describe |
|---|---|---|---|---|---|
| Content-Type | String | Y | N | application/json | |
| cookie | String | Y | N | SHOPLINE cookie |
Request body:
| Parameter name | Parameter type | Required | Array or not | Example | describe |
|---|---|---|---|---|---|
| id | String | Y | N | 36110175633573 | The unique identification of the product is SKU_ id |
| quantity | Long | Y | N | 2 | The quantity of products in the cart after updating the cart item. If the value of this parameter is set to 0 or less, the products will be removed from the cart. |
| 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 |
| properties | Object | N | Y | ![]() | |
| note | String | N | N | Shopping cart notes | Shopping cart notes |
| attributes | Object | N | N | Map<String,String> |
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 | ||||||
| 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 | ||||||
| line_level_total_discount | Double | N | Total amount of commodity bank |
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"
}
}
],
"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"
}
}
],
"line_level_total_discount": 9
}
]
}
Scenario 2: Request Error:
POST https://{handle}.myshopline.com/api/carts/ajax-cart/update.js
status:404
{
"message": "error code",
"description": "error description"
}
Was this article helpful to you?
