Closed beamercola closed 4 years ago
I don't think it is yet–my knowledge of updateAttributes
is pretty thin. You could make use of useClientUnsafe
to get the client object and useCartUnsafe
to get the cart id. Something like this:
function MyComponent() {
const cart = useCartUnsafe()
const setCart = useSetCartUnsafe()
const client = useClientUnsafe()
const newCart = client.checkout.updateAttributes(cart.id, {
customAttributes: [{ key: 'Gift Note', value: 'Test' }],
})
setCart(newCart)
return (<div />);
}
Ah this worked perfectly. I wasn't replacing the cart!
I need to add "Gift Notes" to a cart - I noticed this: https://shopify.github.io/js-buy-sdk/#updating-checkout-attributes
Though I'm having trouble implementing this using the library. Is this possible at this time?