Aleks Per
Aleks Per

Reputation: 1639

Laravel ShoppingCart issue

I need Cart features in my e-commerce site so I decide to use Crinsane. As I read on github docs I run:

composer require gloudemans/shoppingcart

then add line to providers and aliases and to test Cart I write:

public function addvoucher($id)
    {

       $cart = Cart::add(['id' => '293', 'name' => 'Product 1', 'qty' => 1, 'price' => 9.99, 'options' => ['size' => 'large']]);

        return $cart;
    }

route off cource:

Route::get('/addvoucher/{id}', 'VouchersController@addvoucher');

Now when I try to run: localhost:8888/addvoucher/1 I get:

enter image description here

What is a problem? I do everything like on docs... How to properly install this plugin?

UPDATE:

Now I add in VoucherController just: use Cart;

but now I get: enter image description here

Upvotes: 2

Views: 1024

Answers (1)

BlackWhite
BlackWhite

Reputation: 832

You need to import Cart in your controller

write:

use Cart;

in test controller if you add allias for cart in config.

Upvotes: 1

Related Questions