updateLineItemsInCheckout method
Returns the Checkout that checkoutId
belongs to after updating the lineItems
to it.
Implementation
Future<Checkout> updateLineItemsInCheckout({
required String checkoutId,
required List<LineItem> lineItems,
}) async {
final MutationOptions _options = MutationOptions(
document: gql(updateLineItemsInCheckoutMutation),
variables: {
'checkoutId': checkoutId,
'lineItems': [
for (var lineItem in lineItems)
{
'id': lineItem.id,
'variantId': lineItem.variantId,
'quantity': lineItem.quantity,
'customAttributes': lineItem.customAttributes
.map((e) => {
'key': e.key,
'value': e.value,
})
.toList(),
}
],
});
final QueryResult result = await _graphQLClient!.mutate(_options);
checkForError(
result,
key: 'updateLineItemsInCheckout',
errorKey: 'checkoutUserErrors',
);
return Checkout.fromJson(
((result.data!['checkoutLineItemsUpdate'] ?? const {})['checkout'] ??
const {}));
}