use-shopping-cart
use-shopping-cart copied to clipboard
Cart Prefix with a namespace scope for managing different carts for platforms
With Stripe Connect apps, it would be ideal to have a way to separate carts for shoppers based on which merchants they are purchasing from
I'm not sure I completely understand what that entails for use-shopping-cart. Do you want to allow the developer to pass in a string that would be the LocalStorage key? So you'd have
export function CartProvider({ namespace='cart-values', /* other props */ }) {
/* other code */
const [cartValues, cartValuesDispatch] = useLocalStorageReducer(
namespace,
cartValuesReducer,
cartValuesInitialState
)
We could also just call it storageKey
instead of namespace
if that'd make it more obvious what it was doing.
I like the idea of storageKey
, but yeah the idea is to be able to store different carts per merchant based on this storage key