getCartById method

Future<Cart> getCartById(
  1. String cartId
)

Returns a Cart object.

Returns the Cart object of the Cart with the cartId.

Implementation

Future<Cart> getCartById(String cartId) async {
  final cartById = WatchQueryOptions(
    document: gql(getCartByIdQuery),
    variables: {
      'id': cartId,
      'country': ShopifyLocalization.countryCode,
    },
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  QueryResult result = await _graphQLClient!.query(cartById);
  checkForError(result);

  return Cart.fromJson(result.data!['cart'] ?? const {});
}