marksihor/laravel-cart

Laravel Cart

1.01 2020-08-17 14:16 UTC

This package is auto-updated.

Last update: 2024-04-17 22:52:09 UTC


README

Installing

$ composer require marksihor/laravel-cart -vvv

CONFIGURATION

  1. Run the command in your terminal
$ php artisan vendor:publish --provider="MarksIhor\\LaravelCart\\CartServiceProvider" --tag=config
  1. Open config/app.php and add this line to your Aliases
  'Cart' => MarksIhor\LaravelCart\Facades\CartFacade::class,
  1. Open App\Http\Kernel.php and add this line to $routeMiddleware array
  'cart' => \MarksIhor\LaravelCart\Http\Middleware\CartMiddleware::class,
  1. Use "cart" middleware on routes you nedd to access cart

Usage examples

\Cart::addItem([
            'product_id' => $product->id,
            'seller_id' => $product->user_id,
            'attributes' => $attributes,
            'price' => $product->price
        ]);
\Cart::getCart();
\Cart::getCart($cartId);
\Cart::getContentArray();
\Cart::getContentArray($cartId);
\Cart::getContent();
\Cart::getContent($cartId);
\Cart::deleteItem($itemId);
\Cart::clearCart();
\Cart::clearCart($itemId);
\Cart::getTotal($type); // price|total|discount|quantity
\Сart::getTotal($type, $cartId);
\Cart::updateItem($item, $data);

License

MIT