PHP code example of sinbadxiii / phalcon-cart

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

    

sinbadxiii / phalcon-cart example snippets


$di->set(
      'cart',
      function () use ($di) {
          return new Sinbadxiii\Phalcon\Cart\CartShopping(
              $di->getSession()
          );
      }
  );

$di->set(
      'compare',
      function () use ($di) {
          return new Sinbadxiii\Phalcon\Cart\CartShopping(
              $di->getSession(), 'compare'
          );
      }
  );

#add()
$this->cart->add('1', 'Product Name 1', 1, 100.99);

#update()
$rowId = '5d12249fdca4cb0fff77f49bbffc128c';
$this->cart->update($rowId, 10);

#remove()
$rowId = '5d12249fdca4cb0fff77f49bbffc128c';
$this->cart->remove($rowId);

#content()
$this->cart->content();

#destroy()
$this->cart->destroy();

#total() with Tax
$this->cart->total();

#total() without Tax
$this->cart->subtotal();

#count()
$this->cart->count();

#countTotal()
$this->cart->countTotal();

$this->cart->instance('shop')->add('100', 'Product #1', 1, 100.00);

// Get the content of the 'shop' cart
$this->cart->content();

$this->cart->instance('wishlist')->add('200', 'Product #2', 1, 20.00);

// Get the content of the 'wishlist' cart
$this->cart->content();

// If you want to get the content of the 'shopping' cart again
$this->cart->instance('shop')->content();

// And the count of the 'wishlist' cart again
$this->cart->instance('wishlist')->count();