funayaki / cakephp-cart
Cart plugin for CakePHP
Installs: 22
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 3
Type:cakephp-plugin
Requires
- php: >=5.6
- cakephp/cakephp: >=3.3.2 <4.0.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.0
This package is not auto-updated.
Last update: 2024-10-27 05:46:56 UTC
README
Cart plugin for CakePHP
Requirements
- CakePHP 3.5.0 or later
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require funayaki/cakephp-cart
Implement EntityBuyableAwareInterface:
class Item extends Entity implements EntityBuyableAwareInterface { public function getPrice() { return $this->price; } public function getBuyableLimit() { return INF; } }
Load CartComponent:
<?php class AppController extends Controller { public function initialize() { parent::initialize(); $this->loadComponent('Cart.Cart'); } }
Usage
Add item to cart:
$this->Cart->add($item);
Update item quantity in cart:
$this->Cart->edit($item, 5);
Get item(s) in cart:
$this->Cart->get($item); $this->Cart->get();
Calculate item total price in cart:
$this->Cart->total($item);
Calculate total price in cart:
$this->Cart->total();
Count quantity item(s) in cart:
$this->Cart->count($item); $this->Cart->count();
Delete item from cart:
$this->Cart->delete($item);
Delete all items from cart:
$this->Cart->clear();