updateCartItemQuantity method
Updates the quantity of a cart item in Firestore.
Parameters:
- productId: The ID of the product whose quantity is to be updated.
- newQuantity: The new quantity for the cart item.
Returns: A Future<void> that completes when the quantity is updated.
Implementation
Future<void> updateCartItemQuantity(String productId, int newQuantity) async {
try {
await _firestore
.collection('carts')
.doc(userId)
.collection('items')
.doc(productId)
.update({'quantity': newQuantity});
} catch (e) {
print('Error updating cart item quantity: $e');
}
}