PHP code example of mkakpabla / session-shoppingcart

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

    

mkakpabla / session-shoppingcart example snippets




 = new Cart();

$cart->addItem(1, [
    'name' => 'item1',
    'price' => 'item2'
], 2);

// Return the list of the CartItems
$items = $cart->getItems();

// Return the price of the cart
$cartPrice = $items->totalPrice()