Nhảy tới nội dung

my.getCart

getCart

my.getCart là API trả về tổng sản phẩm đang có trong giỏ hàng (cart) của Tiki, được lọc theo sellerId.

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

Demo

Trải nghiệm thử với trình giả lập bên dưới

API Params

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
sellerIdNumberId của nhà bán
successFunctionCallback function khi get cart được thực hiện thành công
failFunctionCallback function khi get cart thất bại, argument sẽ là error message
completeFunctionCallback function khi get cart kết thúc cho dù thành công hay thất bại.

Giá trị trong success callback

Thuộc tínhKiểu dữ liệuMô tả
totalnumberTổng sản phẩm trong giỏ hàng theo sellerId
itemsarrayDanh sách tất cả sản phẩm trong giỏ hàng theo sellerId

Sample Code

index.txml
<view>
<block-header title="Usage" description="Get Cart" />
<view class="block-content">
<button style="width: 100%;" onTap="onGetCart">
Get Cart
</button>
</view>
</view>
index.js
Page({
onGetCart() {
my.getCart({
sellerId: 1,
success: (res) => {
console.log(res);
my.alert({
title: 'Total number of items',
content: res.total
});
},
fail: (res) => {
console.log(res);
}
});
}
});