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 nameParameter typeRequired or notArray or notDefault valuedescribe
Content-TypeStringYNapplication/json
AcceptStringNN*/*The response will return different content-type and status codes based on the request type. The corresponding enumeration values are as follows:
  • \*/\*
    • Response Content-type: text/html; charset=utf-8
    • Status code: 302 , Redirect to the shopping cart page by default.
  • application/json:
    • Response Content-type: application/json; charset=utf-8
    • Status code: 200
  • Request body:

    Parameter nameParameter typeRequiredArray or notExampledescribe
    idStringNN36110175633573The unique identification of the product is SKU_ id
    lineIntegerNN1The 1-based index position of the item in the cart
    quantityLongYN2The number of items added, the number of items in the shopping cart after adding = the original number + the number added this time
    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

    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
  • 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
  • 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
  • benefit_typeIntegerN
  • 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
  • statusStringNThe 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_codeStringNAn error code will be returned when the discount code cannot be applied
    error_messageStringNAn error message will be returned when the discount code cannot be applied
    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
  • 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
  • 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
  • benefit_typeIntegerN
  • 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
  • statusStringNThe 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_codeStringNAn error code will be returned when the discount code cannot be applied
    error_messageStringNAn error message will be returned when the discount code cannot be applied
    line_level_total_discountDoubleNTotal amount of commodity bank
    gift_cardObjectY
    gift_card_codeStringNxxxxxxxxxxxxfb3cGift card code, the last 4 characters of the gift card
    gift_card_statusIntegerN1Gift card status, indicating whether the gift card is available,1=available,0=unavailable
    gift_card_allocated_amountStringN10.00 USDThe amount of gift card deduction in the current shopping cart (currency is the current market settlement currency)
    error_messageStringNThis gift card has reached its usage date.Gift card application error message
    gift_card_use_in_cartBooleanN1Whether 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?