updateCustomerCartItemQuantity method
Update customer cart item quantity
Implementation
Future<Cart> updateCustomerCartItemQuantity({
required int itemId,
required int quantity,
}) async {
try {
final data = {
'cartItem': {'qty': quantity},
};
final response = await _client.authenticatedRequest<Map<String, dynamic>>(
'/rest/V1/carts/mine/items/$itemId',
options: Options(method: 'PUT'),
data: data,
);
if (response.statusCode == 200) {
return Cart.fromJson(response.data!);
} else {
throw Exception(
'Failed to update customer cart item: ${response.statusMessage}',
);
}
} on DioException catch (e) {
throw Exception('Failed to update customer cart item: ${e.message}');
} catch (e) {
throw Exception('Failed to update customer cart item: $e');
}
}