Crinsane / LaravelShoppingcart

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

Non-static method Gloudemans\Shoppingcart\Cart::add() #141

Closed sha-phpnerd closed 8 years ago

sha-phpnerd commented 8 years ago

Non-static method Gloudemans\Shoppingcart\Cart::add() should not be called statically, assuming $this from incompatible context

Im using laravel 5.1 ; there i dont find any static method. Please help !!

Crinsane commented 8 years ago

You should call the add() method on the facade, not on the actual class.

franklinfs commented 8 years ago

use Cart;

ilhamsabar commented 8 years ago

i try use Cart. and i find this eror.. please help. i found same eror

Crinsane commented 8 years ago

@ilhamsabar You will have to use the facade, you're trying to call the add method statically on the actual Cart class.

So don't do use Gloudemans\Shoppingcart\Cart; but use Cart; or use Gloudemans\Shoppingcart\Facades\Cart;.

hengsoheak commented 8 years ago

How to get table for this LaravelShoppingcart packages?

shahidkarimi commented 7 years ago

I tried

    $c = new Cart(?,?);
    $c->add('192ao12', 'Product 1', 1, 9.99);

What to put in the hell two arguments while instantiating?

Crinsane commented 7 years ago

@shahidkarimi You either use the facade and call the add method on that. If you want to create an instance of the cart yourself, either use the service container, so something like app(Cart::class) or let Laravel inject it into the class constructor or something for you. If you really want to do it like the code you showed me, take a look at the actual code to see what it needs.

But there's not really any need to instantiate the cart yourself like that.

arinzehills commented 3 years ago

please I had the same issue i used use Cart; but it gave me a new error saying provide a valid name

Ashraful05 commented 2 years ago

round function is not working. showing a non numeric value encountered, when i use Cart::total(). Please help me.