notrab / react-use-cart

React hook library for managing cart state

Home Page:http://npm.im/react-use-cart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support global cart metadata

notrab opened this issue Β· comments

Similar to what happens with CartQL, it would be good to support a updateCart function that allows you to set global metadata on the cart.

This can be helpful for tracking any order notes, coupon codes, etc.

Example:

const { updateCart } = useCart()

updateCart({
  coupon: 'FREESHIPPING'
})

The only thing that would need decided is how to access this. I'd prefer to namespace this under metadata, so you'd be able to do:

function () {
  const { metadata } = useCart()

  return (
    <p>{metadata.coupon}</p>
  )
}

What should we call this function?

πŸš€ for updateCart
πŸŽ‰ for updateCartMeta
πŸ‘€ for updateCartMetadata

πŸŽ‰ This issue has been resolved in version 1.11.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€