laracart icon indicating copy to clipboard operation
laracart copied to clipboard

Return this cart item (when adding associate model).

Open Augen2203 opened this issue 3 years ago • 2 comments

Hi I started trying to use your package in my application. Thanks.

I would like that when linking the model:

LaraCart::add($product-> id, $product->name,1, $product->price, $cart['options'])->setModel(Product::class); the currently added item to the cart was returned to us, but this does not happen since setModel () returns null.

Why you need to do a similar design

$cart = LaraCart::add($product-> id, $product->name,1, $product->price, $cart['options'])->setModel(Product::class);
$cart->setModel(Product::class);

Thanks

Augen2203 avatar Aug 05 '21 12:08 Augen2203

just needs to return this when I set that model.

lukepolo avatar Aug 05 '21 12:08 lukepolo

There is also a problem with adding two identical products, which should be combined in quantity with each other, but this does not happen, but an error occurs:

"Call to a member function setModel () on null".

The error always appears when adding the same product to the cart a second time.

Thanks

Augen2203 avatar Aug 05 '21 17:08 Augen2203