@@ -18,6 +18,7 @@ class CartCotroller extends GetxController {
18
18
19
19
late dynamic productSnapshot;
20
20
var products = [];
21
+ var placingOrder = false .obs;
21
22
22
23
// calculate total price of item present in cart
23
24
calculateTotalPrice (data) {
@@ -35,6 +36,7 @@ class CartCotroller extends GetxController {
35
36
36
37
// order placing
37
38
placeMyOrder ({required orderPaymentMethod, required totalAmount}) async {
39
+ placingOrder (true );
38
40
await getProductDetails ();
39
41
40
42
await firestore.collection (ordersCollection).doc ().set ({
@@ -57,6 +59,8 @@ class CartCotroller extends GetxController {
57
59
'total_amount' : totalAmount,
58
60
'orders' : FieldValue .arrayUnion (products),
59
61
});
62
+
63
+ placingOrder (false );
60
64
}
61
65
62
66
// product details
@@ -66,9 +70,18 @@ class CartCotroller extends GetxController {
66
70
products.add ({
67
71
'color' : productSnapshot[i]['color' ],
68
72
'image' : productSnapshot[i]['image' ],
73
+ 'vendor_id' : productSnapshot[i]['vendor_id' ],
74
+ 'total_price' : productSnapshot[i]['total_price' ],
69
75
'quantity' : productSnapshot[i]['quantity' ],
70
76
'title' : productSnapshot[i]['title' ],
71
77
});
72
78
}
73
79
}
80
+
81
+ // clear cart
82
+ clearCart () {
83
+ for (var i = 0 ; i < productSnapshot.length; i++ ) {
84
+ firestore.collection (cartCollection).doc (productSnapshot[i].id).delete ();
85
+ }
86
+ }
74
87
}
0 commit comments