checkoutLineItemsReplace method

Future<void> checkoutLineItemsReplace(
  1. String checkoutId,
  2. List<String> variantIdList, {
  3. bool deleteThisPartOfCache = false,
})

Replaces the LineItems in the Checkout associated to the checkoutId.

checkoutLineItems is a List of Variant Ids

Implementation

Future<void> checkoutLineItemsReplace(
  String checkoutId,
  List<String> variantIdList, {
  bool deleteThisPartOfCache = false,
}) async {
  var checkoutLineItems = transformVariantIdListIntoListOfMaps(variantIdList);
  final MutationOptions _options = MutationOptions(
    document: gql(replaceCheckoutItemsMutation),
    variables: {
      'checkoutId': checkoutId,
      'checkoutLineItems': checkoutLineItems,
    },
  );
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'checkoutLineItemsReplace',
    errorKey: 'userErrors',
  );
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }
}