useCartUpdateAttributes

A cart hook that helps you easily update / overwrite cart-level custom attributes.

// import
import { useCartUpdateAttributes } from '@backpackjs/storefront';

// instantiation
const { cartUpdateAttributes, ...updateAttrStatus } = useCartUpdateAttributes();

// use
const updatedAttibutes = [
  { key: "acceptedTAndCs", value: "true" }
]

const customAttributes = await cartUpdateAttributes({
  customAttributes: updatedAttibutes
});

updatedAttibutes

cart custom attributes array [ { key: 'attrKey', value: 'attrValue' }, ... ]

For line_item custom attributes seeuseCartAddItems or useCartUpdateItems

Last updated