funayaki/cakephp-cart

There is no license information available for the latest version (0.0.1) of this package.

Cart plugin for CakePHP

Installs: 20

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 3

Type:cakephp-plugin

0.0.1 2018-12-19 08:58 UTC

This package is not auto-updated.

Last update: 2024-04-14 02:50:14 UTC


README

Build Status Scrutinizer Code Quality codecov

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();