Crinsane / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
3.67k stars 1.73k forks source link

Get total item cart #277

Open devmahmed opened 7 years ago

devmahmed commented 7 years ago

How to get total items in cart?

tchoblond59 commented 7 years ago

You should read the doc man...

https://github.com/Crinsane/LaravelShoppingcart#cartcount

Cart::count();

abr4xas commented 7 years ago

Hey @Crinsane close this please :smile:

decodedmrq commented 5 years ago

Cart::count() is get total qty of total item. Use Cart::content()->count() to get total item in carts.

akinsayo commented 3 months ago

Cart::count() is get total qty of total item. Use Cart::content()->count() to get total item in carts.

This implies that Cart::count() will get the total count of all items in all instances of the cart but it does not work like so. Cart::count() only returns the total items in the last instance of the shopping cart.

If I did

Cart::add('293ad', 'Product 1', 1, 9.99); Cart::instance('test')->add('293ad', 'Product 1', 1, 9.99); Cart::instance('test1')->add('293ad', 'Product 1', 1, 9.99);

Doing Cart:count(), I should expect something like 3 but instead, I will get result for Cart::instance('test')->count() which is 1