PHP code example of cyrkulewski / shopping-cart
1. Go to this page and download the library: Download cyrkulewski/shopping-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/ */
cyrkulewski / shopping-cart example snippets
$product = array(
'id' => 'XYZ',
'qty' => 1,
'price' => 15.15,
'product' => 'Book: ZF2 for beginners',
);
$this->ShoppingCart()->insert($product);
$products = array(
array(
'id' => 'XYZ',
'qty' => 1,
'price' => 15.15,
'product' => 'Book: ZF2 for beginners',
),
array(
'id' => 'ZYX',
'qty' => 3,
'price' => 19.99,
'product' => 'Book: ZF2 for advanced users',
)
);
$this->ShoppingCart()->insert($products);
$token => '4b848870240fd2e976ee59831b34314f7cfbb05b';
$this->ShoppingCart()->remove($token);
$this->ShoppingCart()->destroy();
$this->ShoppingCart()->cart();
$this->ShoppingCart()->total_sum();
$this->ShoppingCart()->total_items();
return new ViewModel(array(
'cart' => $this->ShoppingCart()->cart(),
'total_items' => $this->ShoppingCart()->total_items(),
'total_sum' => $this->ShoppingCart()->total_sum(),
));
$this->ShoppingCart()->setEntityPrototype(new YourModule/Entity/ShoppingCartEntity());