checkoutDiscountCodeApply method

Future<void> checkoutDiscountCodeApply(
  1. String checkoutId,
  2. String discountCode, {
  3. bool deleteThisPartOfCache = false,
})

Applies discountCode to the Checkout that checkoutId belongs to.

Implementation

Future<void> checkoutDiscountCodeApply(String checkoutId, String discountCode,
    {bool deleteThisPartOfCache = false}) async {
  final MutationOptions _options = MutationOptions(
      document: gql(checkoutDiscountCodeApplyMutation),
      variables: {'checkoutId': checkoutId, 'discountCode': discountCode});
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'checkoutDiscountCodeApplyV2',
    errorKey: 'checkoutUserErrors',
  );
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }
}