getCheckoutInfoQuery method

Future<Checkout> getCheckoutInfoQuery(
  1. String checkoutId, {
  2. bool getShippingInfo = true,
  3. bool withPaymentId = false,
})

Returns a Checkout object.

Returns the Checkout object of the checkout with the checkoutId.

Implementation

Future<Checkout> getCheckoutInfoQuery(
  String checkoutId, {
  bool getShippingInfo = true,
  bool withPaymentId = false,
}) async {
  final WatchQueryOptions _optionsRequireShipping = WatchQueryOptions(
    document: gql(getCheckoutInfoAboutShipping),
    variables: {'id': checkoutId},
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  QueryResult result = await _graphQLClient!.query(_optionsRequireShipping);

  final WatchQueryOptions _options = WatchQueryOptions(
    document: gql(
      _requiresShipping(result) == true && getShippingInfo
          ? withPaymentId
                ? getCheckoutInfoWithPaymentId
                : getCheckoutInfo
          : withPaymentId
          ? getCheckoutInfoWithPaymentIdWithoutShipping
          : getCheckoutInfoWithoutShipping,
    ),
    variables: {'id': checkoutId},
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  final QueryResult _queryResult = (await _graphQLClient!.query(_options));
  checkForError(_queryResult);

  return Checkout.fromJson(_queryResult.data!['node']);
}