查询购物车详情

购物车 API 用于客户在会话期间产生的购物车交互,当需要获取购物车详情的时候可调用该接口。

请求信息

API路径:

https://{handle}.myshopline.com/api/carts/ajax-cart

请求header:

参数名参数类型是否必填是否数组默认值描述
Content-TypeStringYNapplication/json
cookieStringYN主站cookie

响应信息

响应body:

一级参数二级参数三级参数四级参数五级参数参数类型是否数组示例描述
tokenStringN36110175633573购物车token
noteStringN购物车备注购物车备注
attributesMap<String,String>N购物车属性
original_total_priceDoubleN购物车商品原价总计
items_subtotal_priceDoubleN购物车商品小计(已扣减商品行优惠)
total_priceDoubleN购物车最后计价(已扣减商品行折扣和购物车折扣)
total_discountDoubleN购物车总计优惠金额(商品行优惠+购物车级别优惠)
total_weightDoubleN商品总计重量
item_countIntegerN购物车商品总数量
requires_shippingBooleanN是否需要发货(只要购物车商品有一个需要发货)
currencyStringN结算币种
cart_level_discount_applicationsObjectY购物车级别优惠信息
amountDoubleN优惠金额
discount_applicationObjectN
typeIntegerN
  • 1:价格优惠
  • 2:折扣
  • 3:免运费
  • 7:赠品
  • 8:固定价优惠
  • 9:最低商品免费
  • 11:第M件优惠
  • 12:买x送y
  • 101:表抵扣金额
  • 102:表抵扣百分比
  • 103:会员折扣
  • 104:优惠码
  • 105:指定购物金
  • 106:点数
  • titleStringN优惠名称
    descriptionStringN优惠描述
    valueDoubleN优惠金额
    created_atStringN活动创建时间
    value_typeStringN折扣活动类型* *percentage 折扣 *fix_amount 固定金额
    target_typeStringN
  • 优惠作用对象
  • line_item 商品
  • shipping_line 运费
  • itemsObjectY购物车商品列表
    idStringN36110175633573商品唯一标识,即sku_id
    group_idStringN0商品组ID
    quantityIntegerN2商品数量
    propertiesLongNimage.png
  • name: 自定义属性名
  • value: 自定义属性值
  • type: 类型,属性枚举有text,picture,link三种类型,text:字符,展示类型为 name: value; picture: 图片,展示类型为name: 通过urls获取渲染出缩略图,缩略图点击弹窗展示,并支持下载;link: 超链,展示类型为name: value,支持点击跳转 到urls第一个
  • show: 是否展示在前台
  • extInfo: 扩展字段
  • variant_idStringN36110175633573商品 sku_id
    titleStringNtest1商品title+sku title 名称+规格
    priceDoubleN200商品 售价
    original_priceDoubleN200商品 原价 (可能为0)
    discounted_priceDoubleN200减去优惠后的价格
    line_priceDoubleN200商品行售价
    original_line_priceDoubleN200商品行原价(可能为0)
    total_discountDoubleN200单个商品的总折扣金额
    discountsObjectY商品行优惠
    amountDoubleN200优惠金额
    titleStringN满100减50优惠名称
    skuStringN红色XL商品 sku_id
    gramsStringN100商品重量 单位g
    taxableBooleanNtrue是否收税
    product_idStringN36110175633573商品 spu_id
    gift_cardBooleanNtrue是否为礼品卡商品
    final_priceDoubleN500商品参与计价的金额
    final_line_priceDoubleN500商品行参与计价的金额
    urlStringNhttps://ddfasdfasdf商品主站链接
    featured_imageStringN
    aspectRatioDoubleN纵横比
    altStringN鼠标悬停提示信息
    heightIntegerN显示高度
    urlStringN图片
    widthIntegerN显示宽度
    imageStringN商品image
    handleStringN商品handle
    requires_shippingStringN是否需要发货
    product_titleStringN商品title
    variant_titleStringN所有规格的拼接
    variant_optionsStringN所有规格枚举
    options_with_valuesStringN规格
    nameStringN规格名称
    valueStringN规格值
    line_level_discount_allocationsStringN商品行优惠信息
    amountDoubleN优惠金额
    discountApplicationStringN
    typeIntegerN
  • 1:价格优惠
  • 2:折扣
  • 3:免运费
  • 7:赠品
  • 8:固定价优惠
  • 9:最低商品免费
  • 11:第M件优惠
  • 12:买x送y
  • 101:表抵扣金额
  • 102:表抵扣百分比
  • 103:会员折扣
  • 104:优惠码
  • 105:指定购物金
  • 106:点数
  • titleStringN优惠名称
    descriptionStringN优惠描述
    valueDoubleN优惠金额
    created_atStringN活动创建时间
    value_typeStringN折扣活动类型:
  • percentage 折扣
  • fix_amount 固定金额
  • target_typeStringN优惠作用对象
  • line_item 商品
  • shipping_line 运费
  • line_level_total_discountDoubleN商品行优惠总金额

    请求、响应示例

    场景1:正常更新购物车

    {
    "token": "a5f1d38bf17f4578959ad0d8e4ff7cac",
    "note": "购物车备注",
    "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": "所有商品满100减90",
    "description": null,
    "value": 90,
    "created_at": null,
    "value_type": "fix_amount",
    "target_type": "line_item"
    }
    }
    ],
    "items": [
    {
    "id": "18053690554475963802050412",
    "properties": null,
    "quantity": 10,
    "title": "自定义商品100个 ",
    "price": 10,
    "discounts": [],
    "sku": "18053690554475963802050412",
    "grams": "0.0",
    "taxable": true,
    "url": "https://{handle}/products/自定义商品100个",
    "image": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
    "handle": "自定义商品100个",
    "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": "自定义商品100个",
    "variant_title": "",
    "variant_options": [],
    "options_with_values": [],
    "line_level_discount_allocations": [],
    "line_level_total_discount": 0
    },
    {
    "id": "18053340946130027787140412",
    "properties": null,
    "quantity": 1,
    "title": "仅仅是限时促销商品 ",
    "price": 10,
    "discounts": [
    {
    "amount": 9,
    "title": "促销活动1"
    }
    ],
    "sku": "18053340946130027787140412",
    "grams": "0.0",
    "taxable": true,
    "url": "https://{handle}//products/仅仅是限时促销商品",
    "image": "https://img.myshopline.com/image/official/e46e6189dd5641a3b179444cacdcdd2a.png",
    "handle": "仅仅是限时促销商品",
    "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": "仅仅是限时促销商品",
    "variant_title": "",
    "variant_options": [],
    "options_with_values": [],
    "line_level_discount_allocations": [
    {
    "amount": 9,
    "discount_application": {
    "type": 8,
    "title": "促销活动1",
    "description": null,
    "value": 9,
    "created_at": null,
    "value_type": null,
    "target_type": "line_item"
    }
    }
    ],
    "line_level_total_discount": 9
    }
    ]
    }

    场景2:请求错误:

    POST https://{handle}.myshopline.com/api/carts/ajax-cart/update.js

    status:404 
    {
    "message": "error code",
    "description": "error description"
    }
    这篇文章对你有帮助吗?