PHP code example of juliobitencourt / laravel-cart

1. Go to this page and download the library: Download juliobitencourt/laravel-cart library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

juliobitencourt / laravel-cart example snippets


'JulioBitencourt\Cart\CartServiceProvider',

use JulioBitencourt\Cart\Cart;

class CartController extends Controller {

	protected $cart;

	public function __construct(Cart $cart)
	{
		$this->cart = $cart;
	}

$item = [
	'sku' => '123456',
	'description' => 'PlayStation 4',
	'price' => 300,
	'quantity' => 1
];

$result = $this->cart->insert($item);

$item = [
	'sku' => '111111',
	'description' => '2 Year Protection',
	'price' => 30.50,
	'quantity' => 1
];

$result = $this->cart->insertChild($parentId, $item);

$result = $this->cart->update($id, $quantity);

$this->cart->delete($id);

$this->cart->destroy();

$this->cart->isEmpty(); // Returns true or false

$this->cart->all();

$this->cart->totalItems();

$this->cart->total();

$this->cart->setEmail($email)
shell
php artisan vendor:publish
shel
php artisan migrate