清空购物车

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

请求信息

API路径:

POST https://{handle}.myshopline.com/cart/clear

请求header:

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

请求body:

一级参数名二级参数名参数类型是否必填是否数组示例描述
sectionsStringNNcart-notification-product,cart-notification-button需要捆绑 section 渲染的 section,多个 section 使用 , 符号分割
sections_urlStringNN/products/dress指定捆绑 section 渲染的页面

响应信息

参见返回示例



请求、响应示例

场景1:正常更新购物车

{
"token": "a90a01c9d11c4b3aa51533765d43ab79",
"note": null,
"attributes": {},
"totalPrice": 0,
"totalWeight": 0,
"itemCount": 0,
"items": [],
"requiresShipping": false,
"sections": {}
}

场景2:请求错误:

POST https://{handle}.myshopline.com/cart/clear

status:404 
{
"message": "error code",
"description": "error description"
}

场景3:捆绑 section 渲染:

POST https://{handle}.myshopline.com/cart/update

{
"token": "a90a01c9d11c4b3aa51533765d43ab79",
"note": null,
"attributes": {},
"totalPrice": 0,
"totalWeight": 0,
"itemCount": 0,
"items": [],
"requiresShipping": false,
"sections": {
"cart-notification-product": "<div id=\"shopline-section-cart-notification-product\" class=\"shopline-section\"><link rel=\"dns-prefetch\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" crossorigin>\n<link rel=\"dns-prefetch\" href=\"https://fonts.gstatic.com\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Montserrat:500|Poppins:300&display=swap\" media=\"all\"> <div id=\"cart-notification-product-18062607064090484554672730:6dbf69a53a854f65ab2e23e783a7dcff\" class=\"cart-item\">\n <div class=\"cart-notification-product__image global-media-border-shadow\">\n <img\n src=\"https://d2n979dmt31clo.cloudfront.net/image/store/1655365532096/-_200x.jpeg?w=275&h=183\"\n alt=\"\"\n width=\"100\"\n height=\"67\"\n loading=\"lazy\"\n />\n </div>\n <div class=\"cart-notification-product__details\">\n <div class=\"cart-notification-product__name body2\">三文鱼鱼籽</div>\n\n </div>\n </div>\n</div>",
"cart-notification-button": "<div id=\"shopline-section-cart-notification-button\" class=\"shopline-section\"><link rel=\"dns-prefetch\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" crossorigin>\n<link rel=\"dns-prefetch\" href=\"https://fonts.gstatic.com\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Montserrat:500|Poppins:300&display=swap\" media=\"all\"><div class=\"cart-notification-button\">View cart (6)</div></div>",
"cart-icon-bubble": "<div id=\"shopline-section-cart-icon-bubble\" class=\"shopline-section\"><link rel=\"dns-prefetch\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" crossorigin>\n<link rel=\"dns-prefetch\" href=\"https://fonts.gstatic.com\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Montserrat:500|Poppins:300&display=swap\" media=\"all\"><div id=\"cart-icon-bubble-wrapper\">\n <svg class=\"icon icon-cart\" width=\"18\" height=\"20\" viewBox=\"0 0 18 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M1.10959 19L1 6H17L16.8904 19H1.10959Z\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M5 6V5C5 2.79086 6.79086 1 9 1V1C11.2091 1 13 2.79086 13 5V6\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n\n <span class=\"header__cart-point body6\">6</span>\n</div>\n</div>",
"cart-notification-subtotal": "<div id=\"shopline-section-cart-notification-subtotal\" class=\"shopline-section\"><link rel=\"dns-prefetch\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" crossorigin>\n<link rel=\"dns-prefetch\" href=\"https://fonts.gstatic.com\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Montserrat:500|Poppins:300&display=swap\" media=\"all\"><div class=\"cart-notification-subtotal\">\n <em class=\"body2\">Cart subtotal</em>\n <span class=\"body1 fw-bold\">HK$0.00</span>\n</div></div>"
}
}
这篇文章对你有帮助吗?