getCartTotals method

Future<CartTotals> getCartTotals(
  1. String cartId
)

Get cart totals

Implementation

Future<CartTotals> getCartTotals(String cartId) async {
  try {
    final response = await _client.guestRequest<Map<String, dynamic>>(
      '/rest/V1/guest-carts/$cartId/totals',
    );

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