removeFromCustomerCart method

Future<Cart> removeFromCustomerCart(
  1. int itemId
)

Remove item from customer cart

Implementation

Future<Cart> removeFromCustomerCart(int itemId) async {
  try {
    final response = await _client.authenticatedRequest<Map<String, dynamic>>(
      '/rest/V1/carts/mine/items/$itemId',
      options: Options(method: 'DELETE'),
    );

    if (response.statusCode == 200) {
      return Cart.fromJson(response.data!);
    } else {
      throw Exception(
        'Failed to remove item from customer cart: ${response.statusMessage}',
      );
    }
  } on DioException catch (e) {
    throw Exception('Failed to remove item from customer cart: ${e.message}');
  } catch (e) {
    throw Exception('Failed to remove item from customer cart: $e');
  }
}