LaravelShoppingcart icon indicating copy to clipboard operation
LaravelShoppingcart copied to clipboard

Get total item cart

Open devmahmed opened this issue 8 years ago • 4 comments

How to get total items in cart?

devmahmed avatar Feb 07 '17 08:02 devmahmed

You should read the doc man...

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

Cart::count();

tchoblond59 avatar Feb 07 '17 09:02 tchoblond59

Hey @Crinsane close this please :smile:

abr4xas avatar Feb 07 '17 21:02 abr4xas

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

decodedmrq avatar Oct 14 '19 09:10 decodedmrq

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

akinsayo avatar Jul 06 '24 15:07 akinsayo