PHP code example of edwinylil1 / laravelshoppingcart

1. Go to this page and download the library: Download edwinylil1/laravelshoppingcart 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/ */

    

edwinylil1 / laravelshoppingcart example snippets


    'default_aliquot' => 0,
    'taxes' => [
        '0' => [
            'name' => 'GENERAL',
            'value' => 16.00
        ],
        '1' => [
            'name' => 'EXEMPT',
            'value' => 0.00
        ],
        '2' => [
            'name' => 'REDUCED',
            'value' => 8.00
        ],
        '3' => [
            'name' => 'LUXURY',
            'value' => 31.00
        ]
    ]

    $rowId = '26d21fe340e373e8e7e20f87e0860b74';
    Cart::update($rowId, 2);

    $rowId = '26d21fe340e373e8e7e20f87e0860b74';   
    Cart::update($rowId, ['name' => 'new name']);
    Cart::update($rowId, $product);

    Cart::content();

    Cart::instance('wishlist')->content();

    $rowId = '26d21fe340e373e8e7e20f87e0860b74';   
    Cart::get($rowId);

    $cart->search(function ($cartItem, $rowId) {
        return $cartItem->name === 'tube';
    });

    Cart::total();

    Cart::tax();

    Cart::subtotal();

    Cart::count();

    Cart::addCost($name, $price)

    Cart::getCost($name)

    $rowId = '26d21fe340e373e8e7e20f87e0860b74';   
    Cart::remove($rowId);

Cart::destroy();

    Cart::instance('Instance name');

    Cart::instance('shopping')->add('code', 'Product 1', 1, 9.99);

    // Get the content of the 'shopping' cart
    Cart::content();

    Cart::instance('wishlist')->add('code', 'Product 2', 1, 19.95, 1, ['image' => 'url image']);

    // Get the content of the 'wishlist' cart
    Cart::content();

    // If you want to get the content of the 'shopping' cart again
    Cart::instance('shopping')->content();

    // And the count of the 'wishlist' cart again
    Cart::instance('wishlist')->count();

    Cart::store('username');

    Cart::instance('custom name')->store('code');

    Cart::restore('username');

    Cart::instance('custom name')->restore('code');

    Cart::content()->count();

    Cart::content()->groupBy('id');

    // First we'll add the item to the cart.
    $cartItem = Cart::add('code', 'Product name', 1, 9.99);

    // Next we associate a model with the item.
    Cart::associate($cartItem->rowId, 'Product');

    // Or even easier, call the associate method on the CartItem!
    $cartItem->associate('Product');

    // You can even make it a one-liner
    Cart::add('code', 'Product name', 1, 9.99)->associate('Product');

    // Now, when iterating over the content of the cart, you can access the model.
    foreach(Cart::content() as $row) {
        echo 'You have ' . $row->qty . ' items of ' . $row->model->name . ' with description: "' . $row->model->description . '" in your cart.';
    }
bash
nano config/app.php
bash
    php artisan vendor:publish --provider="JeleDev\Shoppingcart\ShoppingcartServiceProvider" --tag="config"
bash
    php artisan vendor:publish --provider="JeleDev\Shoppingcart\ShoppingcartServiceProvider" --tag="config"
bash
    php artisan vendor:publish --provider="JeleDev\Shoppingcart\ShoppingcartServiceProvider" --tag="migrations"