wagnerwagner / merx

Merx is a plugin to create online shops with Kirby.
https://merx.wagnerwagner.de
102 stars 10 forks source link

Add method to cart instance to get count based on item quantity #15

Open bezin opened 4 years ago

bezin commented 4 years ago

Hello,

it would be nice to add a new method to the cart object to get the total number of items based on quantity, eg.

// Cart contains two items A and B, A with quantity 1, B with quantity 3

cart()->count() // Returns 2, because 2 items
cart()->countQuantity() // Return 4, because 1 A and 3 B

One could use this method to display the total number of items in cart in the page header. Might be better added to ProductList rather than cart.

Cheerio