Skip to content

Latest commit

 

History

History
70 lines (56 loc) · 1.13 KB

File metadata and controls

70 lines (56 loc) · 1.13 KB

Quick start

This is an explanation of how getting it set up pretty quick without customization. If you want you can customize everything, take a look at the code and documentation for details.

In your AppController

class AppController extends Controller {

	public $components = array(
		'Cart.CartManager'
	);

	public $helpers = array(
		'Cart.Cart'
	);

	public function beforeRender() {
		parent::beforeRender();
	}
}

In your model

class Product extends AppModel {

	public $actsAs = array(
		'Cart.Buyable'
	);
}

In your views:

Buy things via GET

echo $this->Cart->link(__('buy me'), array(
	'item' => $item['Item']['id']
));

Buy things via POST

echo $this->Form->create('Product', array(
	'url' => array(
		'action' => 'buy'
	)
));
echo $this->Form->input('quantity', array(
	'label' => false,
	'default' => 1
));
echo $this->Form->submit(__('buy me'), array(
	'div' => false
));
echo $this->Form->hidden('foreign_key', array(
	'value' => $product['Product']['id']
));
echo $this->Form->hidden('model', array(
	'value' => 'Product'
));