# cartLinesUpdateDefault Creates a function that accepts an array of [CartLineUpdateInput](https://shopify.dev/docs/api/storefront/2024-01/input-objects/CartLineUpdateInput) and updates the line items in a cart ```js import {cartLinesUpdateDefault} from '@shopify/hydrogen'; const cartUpdate = cartLinesUpdateDefault({ storefront, getCartId, }); const result = await cartUpdate([ { id: 'gid://shopify/CartLine/123456789', quantity: 2, }, ]); ``` ## cartLinesUpdateDefault ### CartLinesUpdateDefaultGeneratedType #### Returns: CartLinesUpdateFunction #### Params: - options: CartQueryOptions export function cartLinesUpdateDefault( options: CartQueryOptions, ): CartLinesUpdateFunction { return async (lines, optionalParams) => { const {cartLinesUpdate, errors} = await options.storefront.mutate<{ cartLinesUpdate: CartQueryData; errors: StorefrontApiErrors; }>(CART_LINES_UPDATE_MUTATION(options.cartFragment), { variables: { cartId: options.getCartId(), lines, ...optionalParams, }, }); return formatAPIResult(cartLinesUpdate, errors); }; } ### CartQueryOptions ### storefront value: `Storefront` The storefront client instance created by [`createStorefrontClient`](docs/api/hydrogen/latest/utilities/createstorefrontclient). ### getCartId value: `() => string` A function that returns the cart ID. ### cartFragment value: `string` The cart fragment to override the one used in this query. ### Storefront Interface to interact with the Storefront API. ### query value: `(query: RawGqlString, ...options: IsOptionalVariables> extends true ? [(StorefrontCommonExtraParams & Pick & ClientVariables>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }, Record<"variables", RawGqlString extends never ? { [KeyType in keyof ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }>>)?] : [StorefrontCommonExtraParams & Pick & ClientVariables>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }, Record<"variables", RawGqlString extends never ? { [KeyType in keyof ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontQueries[RawGqlString]["variables"] as Filter>]: StorefrontQueries[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }>>]) => Promise & StorefrontError>` ### mutate value: `(mutation: RawGqlString, ...options: IsOptionalVariables> extends true ? [(StorefrontCommonExtraParams & ClientVariables>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }, Record<"variables", RawGqlString extends never ? { [KeyType in keyof ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }>>)?] : [StorefrontCommonExtraParams & ClientVariables>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }, Record<"variables", RawGqlString extends never ? { [KeyType in keyof ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)]: ({ [KeyType in keyof StorefrontMutations[RawGqlString]["variables"] as Filter>]: StorefrontMutations[RawGqlString]["variables"][KeyType]; } & Partial>>)[KeyType]; } : { readonly [variable: string]: unknown; }>>]) => Promise & StorefrontError>` ### cache value: `Cache` ### CacheNone value: `() => NoStoreStrategy` ### CacheLong value: `(overrideOptions?: AllCacheOptions) => AllCacheOptions` ### CacheShort value: `(overrideOptions?: AllCacheOptions) => AllCacheOptions` ### CacheCustom value: `(overrideOptions: AllCacheOptions) => AllCacheOptions` ### generateCacheControlHeader value: `(cacheOptions: AllCacheOptions) => string` ### getPublicTokenHeaders value: `(props?: Partial> & Pick) => Record` ### getPrivateTokenHeaders value: `(props?: Partial> & Pick & { buyerIp?: string; }) => Record` ### getShopifyDomain value: `(props?: Partial>) => string` ### getApiUrl value: `(props?: Partial>) => string` ### isApiError value: `(error: any) => boolean` ### i18n value: `TI18n` ### StorefrontCommonExtraParams ### headers value: `HeadersInit` ### storefrontApiVersion value: `string` ### displayName value: `string` ### CachingStrategy Use the `CachingStrategy` to define a custom caching mechanism for your data. Or use one of the pre-defined caching strategies: CacheNone, CacheShort, CacheLong. ### mode value: `string` The caching mode, generally `public`, `private`, or `no-store`. ### maxAge value: `number` The maximum amount of time in seconds that a resource will be considered fresh. See `max-age` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#:~:text=Response%20Directives-,max%2Dage,-The%20max%2Dage). ### staleWhileRevalidate value: `number` Indicate that the cache should serve the stale response in the background while revalidating the cache. See `stale-while-revalidate` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-while-revalidate). ### sMaxAge value: `number` Similar to `maxAge` but specific to shared caches. See `s-maxage` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#s-maxage). ### staleIfError value: `number` Indicate that the cache should serve the stale response if an error occurs while revalidating the cache. See `stale-if-error` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-if-error). ### StorefrontError ### errors value: `StorefrontApiErrors` ### NoStoreStrategy ### mode value: `string` ### AllCacheOptions Override options for a cache strategy. ### mode value: `string` The caching mode, generally `public`, `private`, or `no-store`. ### maxAge value: `number` The maximum amount of time in seconds that a resource will be considered fresh. See `max-age` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#:~:text=Response%20Directives-,max%2Dage,-The%20max%2Dage). ### staleWhileRevalidate value: `number` Indicate that the cache should serve the stale response in the background while revalidating the cache. See `stale-while-revalidate` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-while-revalidate). ### sMaxAge value: `number` Similar to `maxAge` but specific to shared caches. See `s-maxage` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#s-maxage). ### staleIfError value: `number` Indicate that the cache should serve the stale response if an error occurs while revalidating the cache. See `stale-if-error` in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-if-error). ### CartLinesUpdateFunction #### Returns: Promise #### Params: - lines: CartLineUpdateInput[] - optionalParams: CartOptionalInput export type CartLinesUpdateFunction = ( lines: CartLineUpdateInput[], optionalParams?: CartOptionalInput, ) => Promise; ### CartOptionalInput ### cartId value: `string` The cart id. ### country value: `CountryCode` The country code. ### language value: `LanguageCode` The language code. ### CartQueryData ### cart value: `Cart` ### userErrors value: `CartUserError[] | MetafieldsSetUserError[] | MetafieldDeleteUserError[]`