removeLineItemsFromCart method

Future<Cart> removeLineItemsFromCart({
  1. required String cartId,
  2. required List<String> lineIds,
})

remove line item from cart

Implementation

Future<Cart> removeLineItemsFromCart({
  required String cartId,
  required List<String> lineIds,
}) async {
  final MutationOptions removeLineItem = MutationOptions(
    document: gql(removeLineItemFromCartMutation),
    variables: {
      'cartId': cartId,
      'lineIds': lineIds,
      'country': ShopifyLocalization.countryCode
    },
  );
  QueryResult result = await _graphQLClient!.mutate(removeLineItem);
  checkForError(result, key: 'cartLinesRemove', errorKey: 'userErrors');

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