Skip to main content

cartLinesAddDefault

Creates a function that accepts an array of CartLineInput and adds the line items to a cart

Anchor to options
options
required

CartLinesAddFunction

export type = ( lines: [], optionalParams?: , ) => Promise<>;
Examples

JavaScript

import {cartLinesAddDefault} from '@shopify/hydrogen';

const cartAdd = cartLinesAddDefault({
storefront,
getCartId,
});

const result = await cartAdd([
{
merchandiseId: 'gid://shopify/ProductVariant/123456789',
quantity: 1,
},
]);
Was this page helpful?