addToCart method
Implementation
addToCart(CustomerWishlist customerWishlist, int index) async {
loadingList.add(index);
update();
String deliveryMethod = '';
if (customerWishlist.deliveryMethod == 0) {
deliveryMethod = "PICKUP";
} else if (customerWishlist.deliveryMethod == 1) {
deliveryMethod = "REGULAR";
} else if (customerWishlist.deliveryMethod == 2) {
deliveryMethod = "INSTANT";
}
final request = AddCartRequest(
productId: customerWishlist.productID,
skuId: customerWishlist.skuID,
branchId: customerWishlist.branchID,
deliveryMethod: deliveryMethod,
orderQuantity: 1,
isFlexiSelection: 1,
);
final result = await cartService.addCart(request);
result.fold(
(failure) {
onError?.call(failure.message);
},
(result) {
onSuccess?.call("success_added_prodct".tl);
},
);
loadingList.remove(index);
update();
}