Skip to main content

cartMetafieldsSetDefault
utility

Creates a function that accepts an array of CartMetafieldsSetInput without ownerId and set the metafields to a cart

required

CartMetafieldsSetFunction

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

Example

JavaScript

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

const cartSetMetafields = cartMetafieldsSetDefault({
storefront,
getCartId,
});

const result = await cartSetMetafields([
{
key: 'custom.gift',
type: 'boolean',
value: 'true',
},
]);