, (*1)
Cart plugin for CakePHP
Requirements
Installation
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install composer packages is:, (*3)
composer require funayaki/cakephp-cart
Implement EntityBuyableAwareInterface:, (*4)
class Item extends Entity implements EntityBuyableAwareInterface
{
public function getPrice()
{
return $this->price;
}
public function getBuyableLimit()
{
return INF;
}
}
Load CartComponent:, (*5)
<?php
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
$this->loadComponent('Cart.Cart');
}
}
Usage
Add item to cart:, (*6)
$this->Cart->add($item);
Update item quantity in cart:, (*7)
$this->Cart->edit($item, 5);
Get item(s) in cart:, (*8)
$this->Cart->get($item);
$this->Cart->get();
Calculate item total price in cart:, (*9)
$this->Cart->total($item);
Calculate total price in cart:, (*10)
$this->Cart->total();
Count quantity item(s) in cart:, (*11)
$this->Cart->count($item);
$this->Cart->count();
Delete item from cart:, (*12)
$this->Cart->delete($item);
Delete all items from cart:, (*13)
$this->Cart->clear();