Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

msaad's avatar
Level 1

Laravel Shopping Cart

Hello Friends, I want to ask that I am using the cart package in laravel.

in Controller:

use Gloudemans\Shoppingcart\Cart;

  Cart::add([
            ['id' => '293ad', 'name' => 'Product 1', 'qty' => 1, 'price' => 10.00, 'weight' => 550],
            ['id' => '4832k', 'name' => 'Product 2', 'qty' => 1, 'price' => 10.00, 'weight' => 550, 'options' => ['size' => 'large']]
        ]);

it shows this msg with curly lines below the code:

The non-static method 'add' should not be called statically.intelephense(1036

in vs code

What Is the Reason Plz Help Me?

0 likes
4 replies
lemmon's avatar
lemmon
Best Answer
Level 28

@msaad

change:

use Gloudemans\Shoppingcart\Cart;

to this:

use Gloudemans\Shoppingcart\Facades\Cart;

use the facade.

msaad's avatar
Level 1

I also want to ask that Gloudemans Shoppingcart supports laravel 8 or not

Please or to participate in this conversation.