Returns the current array of `metafields` applied to the checkout. You can optionally filter the list.
Returns the current array of `metafields` applied to the checkout. You can optionally filter the list.
filters: MetafieldsFilters
export function useMetafields< ID extends RenderExtensionPoint = RenderExtensionPoint, >(filters?: MetafieldsFilters): Metafield[] { const metaFields = useSubscription(useApi<ID>().metafields); return useMemo(() => { if (filters) { const {namespace, key} = filters; if (!namespace) { throw new CheckoutUIExtensionError( 'You must pass in a namespace with a key', ); } const filteredResults = metaFields.filter( (metafield) => metafield.namespace === namespace && (!key || metafield.key === key), ); return filteredResults; } return metaFields; }, [filters, metaFields]); }
Metadata associated with the checkout.
The name of the metafield. It must be between 3 and 30 characters in length (inclusive).
A container for a set of metafields. You need to define a custom namespace for your metafields to distinguish them from the metafields used by other apps. This must be between 2 and 20 characters in length (inclusive).
The information to be stored as metadata.
The metafield’s information type.