Skip to main content

cartCreateDefault
utility

Creates a function that accepts an object of CartInput and returns a new cart

required

CartCreateFunction

export type = ( input: , optionalParams?: , ) => Promise<>;
Was this section helpful?

Example

JavaScript

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

const cartCreate = cartCreateDefault({
storefront,
getCartId,
});

const result = await cartCreate({
lines: [
{
merchandiseId: 'gid://shopify/ProductVariant/123456789',
quantity: 1,
},
],
});