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 nameParameter typeRequired or notArray or notDefault valuedescribe
Content-TypeStringYNapplication/json
cookieStringYNSHOPLINE cookie

Request body:

Parameter nameParameter typeRequiredArray or notExampledescribe
idStringYN36110175633573The unique identification of the product is SKU_ id
quantityLongYN2The 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.
groupIdStringNN0Item 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
propertiesObjectNY image.png
  • Name(required): User-defined attribute name
  • Value: custom attribute value
  • 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
  • Show: Whether to display at the front desk
  • ExtInfo: extended field
  • noteStringNNShopping cart notesShopping cart notes
    attributesObjectNNMap<String,String>

    Response information

    Response body:

    Parameter nameParameter typeArray or notExampledescribe
    tokenStringN36110175633573Shopping cart token
    noteStringNShopping cart notesShopping cart notes
    attributesMap<String,String>NShopping cart properties
    original_total_priceDoubleNTotal original price of shopping cart goods
    items_subtotal_priceDoubleNSubtotal of shopping cart goods (discount of business conduct has been deducted)
    total_priceDoubleNFinal pricing of shopping cart (discount of commodity and shopping cart have been deducted)
    total_discountDoubleNTotal discount amount of shopping cart (commodity line discount + shopping cart level discount)
    total_weightDoubleNTotal weight of goods
    item_countIntegerNTotal quantity of goods in shopping cart
    requires_shippingBooleanNWhether shipment is required (as long as one item in the shopping cart needs to be shipped)
    currencyStringNsettlement currency
    cart_level_discount_applicationsObjectYShopping cart level discount information
    amountDoubleNPreferential amount
    discount_applicationObjectN
    typeIntegerN
  • 1: Price concessions
  • 2: discount
  • 3: freight free
  • 7: gifts
  • 8: fixed price discount
  • 9: free minimum goods
  • 11: m-PIECE discount
  • 12: buy x get y free
  • 101: table deduction amount
  • 102: table deduction percentage
  • 103: member discount
  • 104: discount code
  • 105: designated shopping money
  • 106: points
  • titleStringNPreferential name
    descriptionStringNOffer describe
    valueDoubleNPreferential amount
    created_atStringNActivity creation time
    value_typeStringNDiscount activity type:
  • Percentage discount
  • fix_ Amount fixed amount
  • target_typeStringN
  • Preferential target
  • line_ Item item
  • shipping_ Line freight
  • itemsObjectYShopping cart item list
    idStringN36110175633573The unique identification of the product is SKU_ id
    group_idStringN0Item group ID
    quantityIntegerN2Quantity of goods
    propertiesLongNimage.png
  • Name: User-defined attribute name
  • Value: custom attribute value
  • 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
  • Show: Whether to display at the front desk
  • ExtInfo: extended field
  • variant_idStringN36110175633573Item SKU_ id
    titleStringNtest1Product title + SKU title name + specification
    priceDoubleN200Commodity price
    original_priceDoubleN200Original price of goods (may be 0)
    discounted_priceDoubleN200Price after discount
    line_priceDoubleN200Commodity line selling price
    original_line_priceDoubleN200Original price of commodity line (may be 0)
    total_discountDoubleN200Total discount amount of a single item
    discountsObjectYDiscount of commodity bank
    amountDoubleN200Preferential amount
    titleStringN50 minus 100Preferential name
    skuStringNRed XLItem SKU_ id
    gramsStringN100Commodity weight unit: G
    taxableBooleanNtrueWhether to collect tax
    product_idStringN36110175633573Commodity SPU_ id
    gift_cardBooleanNtrueIs it a gift card product
    final_priceDoubleN500Amount of goods involved in pricing
    final_line_priceDoubleN500Amount of commodity line participating in pricing
    urlStringNhttps://ddfasdfasdfCommodity master link
    featured_imageStringN
    aspectRatioDoubleNAspect ratio
    altStringNMouse over prompt
    heightIntegerNDisplay height
    urlStringNpicture
    widthIntegerNDisplay width
    imageStringNProduct image
    handleStringNProduct handle
    requires_shippingStringNWhether shipment is required
    product_titleStringNProduct title
    variant_titleStringNSplicing of all specifications
    variant_optionsStringNEnumeration of all specifications
    options_with_valuesStringNSpecifications
    nameStringNSpecifications name
    valueStringNSpecifications value
    line_level_discount_allocationsStringNDiscount of commodity bank information
    amountDoubleNPreferential amount
    discountApplicationStringN
    typeIntegerN
  • 1: Price concessions
  • 2: discount
  • 3: freight free
  • 7: gifts
  • 8: fixed price discount
  • 9: free minimum goods
  • 11: m-PIECE discount
  • 12: buy x get y free
  • 101: table deduction amount
  • 102: table deduction percentage
  • 103: member discount
  • 104: discount code
  • 105: designated shopping money
  • 106: points
  • titleStringNPreferential name
    descriptionStringNOffer describe
    valueDoubleNPreferential amount
    created_atStringNActivity creation time
    value_typeStringNDiscount activity type:
  • Percentage discount
  • fix_ Amount fixed amount
  • target_typeStringN
  • Preferential target
  • line_ Item item
  • shipping_ Line freight
  • line_level_total_discountDoubleNTotal 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?