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 multiple cart item types

notrab opened this issue · comments

Similar to CartQL, it would be helpful to group cart items based on their type.

For example, SKU, TAX, SHIPPING would permit new subTotal, taxTotal, grandTotal, and shippingTotal values.

This would be great.

@luis-cruzt can you tell me a bit more about your use case?

I'm thinking addItem takes a type as mentioned above that is either SKU, TAX, or SHIPPING, and updates the correct totals.

SKU would be the default. I think this is a fairly basic implementation that stays very agnostic to the implementation.

Thinking about this some more, TAX will most likely need to be added to the Item type, as items can have their own tax amounts.

Shipping would also be a new type that doesn't have a quantity, but you can add multiple shipping items with different IDs.

Actually the way you are describing it's correct, as for some items sometimes they have their own tax amount, I think is a nice approach.

In my use case is very basic, because my client already included the tax amount per item (don't know why).

Why is this being closed?