removeCoupon method

Future<Cart> removeCoupon(
  1. String cartId
)

Remove coupon from cart

Implementation

Future<Cart> removeCoupon(String cartId) async {
  try {
    final response = await _client.guestRequest<Map<String, dynamic>>(
      '/rest/V1/guest-carts/$cartId/coupons',
      options: Options(method: 'DELETE'),
    );

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