clearCart method
Clears all items from the user's cart in Firestore.
Returns: A Future<void> that completes when the cart is cleared.
Implementation
Future<void> clearCart() async {
try {
final snapshot = await _firestore
.collection('carts')
.doc(userId)
.collection('items')
.get();
for (DocumentSnapshot doc in snapshot.docs) {
await doc.reference.delete();
}
} catch (e) {
print('Error clearing cart: $e');
}
}