Skip to content
Browse files

Fresh install, with several placeholder files

  • Loading branch information...
1 parent 70af204 commit 601e2687bc2f230b6aa3e74bc44a584f114cfb9e Dean Sofer committed Jul 21, 2009
View
7 cart_app_controller.php
@@ -0,0 +1,7 @@
+<?php
+
+class CartAppController extends AppController {
+
+}
+
+?>
View
7 cart_app_model.php
@@ -0,0 +1,7 @@
+<?php
+
+class CartAppModel extends AppModel {
+
+}
+
+?>
View
14 controllers/cart_products_controller.php
@@ -0,0 +1,14 @@
+<?php
+class CartProductsController extends CartAppController {
+
+ var $name = 'CartProducts';
+ var $components = array('Cart.CartSession');
+ var $helpers = array('Html', 'Form');
+ var $scaffold;
+
+ function addItem($id = null, $options = null) {
+ $this->CartSession->addItem($id);
+ }
+
+}
+?>
View
492 controllers/components/cart_session.php
@@ -0,0 +1,492 @@
+<?php
+
+
+/**
+ * Cart Session Component
+ * Part of the ShoppingCart plugin
+ *
+ * @author Dean Sofer (ProLoser), Jesse Adams (techno-geek)
+ * @version 0.3
+ * @package CakePHP Shopping Cart Plugin Suite
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+ class CartSessionComponent extends Object {
+
+
+ var $components = array('Session');
+ /**
+ * Used to determine wether or not the table should be used
+ *
+ * @var boolean
+ * @access public
+ */
+ var $useTable;
+ /**
+ * Default table field for product names
+ *
+ * @var string
+ * @access public
+ */
+ var $nameField = 'name';
+ /**
+ * Default table field for product descriptions
+ *
+ * @var string
+ * @access public
+ */
+ var $descField = 'description';
+ /**
+ * Default table field for product prices
+ *
+ * @var string
+ * @access public
+ */
+ var $priceField = 'price';
+ /**
+ * Default table field for product taxable boolean. Set to false
+ * to make all products taxable or if there is no taxable field
+ *
+ * @var string
+ * @access public
+ */
+ var $taxableField = 'taxable';
+ /**
+ * The tax rate to be applied during calcTotal()
+ *
+ * @var decimal
+ * @access public
+ */
+ var $taxRate = 0;
+ /**
+ * The shipping rate to be applied during calcTotal()
+ *
+ * @var decimal
+ * @access public
+ */
+ var $shipRate = 0;
+ /**
+ * Specifies wether the shipping rate is a flat rate (true) or
+ * percentage (false)
+ *
+ * @var boolean
+ * @access public
+ */
+ var $shipFlat = true;
+
+
+ /**
+ * Initializes the component, gets a reference to the controller
+ * and stores configuration options.
+ *
+ * @param object $controller A reference to the controller
+ * @param array $options Passed component configuration settings
+ * @return void
+ * @access public
+ */
+ function initialize(&$controller, $options) {
+ // saving the controller reference for later use
+ $this->controller =& $controller;
+
+
+ if (isset($options['useTable'])) {
+ $this->useTable = $options['useTable'];
+ } else {
+ $this->useTable = $this->controller->{$this->controller->modelClass}->useTable;
+ }
+
+
+ if (isset($options['nameField'])) {
+ $this->nameField = $options['nameField'];
+ } else {
+ $this->nameField = $this->controller->{$this->controller->modelClass}->displayField;
+ }
+ if (isset($options['priceField'])) {
+ $this->priceField = $options['priceField'];
+ }
+ if (isset($options['taxableField'])) {
+ $this->taxableField = $options['taxableField'];
+ }
+ }
+ //called after Controller::beforeFilter()
+ function startup(&$controller) {
+ }
+ //called after Controller::beforeRender()
+ function beforeRender(&$controller) {
+ }
+ //called after Controller::render()
+ function shutdown(&$controller) {
+ }
+ //called before Controller::redirect()
+ function beforeRedirect(&$controller, $url, $status=null, $exit=true) {
+ }
+
+
+ /**
+ * Creates a fresh new cart with empty information
+ *
+ * @param boolean $full Specifies wether or not to retain the user
+ * Billing and Shipping info
+ * @return <success> boolean Session->write() success
+ * @access public
+ */
+ function resetCart($full = true) {
+ $data = null;
+ if ($data = $this->Session->read('Order') && !$full) {
+ unset($data['LineItem'], $data['Billing'], $data['Shipping'], $data['Total']);
+ return $this->Session->write('Order', $data);
+ } else {
+ return $this->Session->delete('Order');
+ }
+ }
+
+
+ /**
+ * Add's an item to the cart, requires a Product.id number or data
+ *
+ * @param int/array $product The product ID from the table, or a custom
+ * array that has the ID field if useTable = true
+ * @return <success> boolean
+ * @access public
+ */
+ function addItem($data, $quantity = 1, $attribs = array()) {
+ // Handles the 3 possible ways to pass a product:
+ // $product = 3, Merges database data with custom data
+ // $product['Model']['id'] = 3, Merges database data with custom data
+ // $product['id'] = 3, Custom products only, for use without a table
+ $lineItem = array();
+ if ($this->useTable) {
+ if (is_array($data)) {
+ $product = $this->controller->{$this->controller->modelClass}->find('first', array('recursive' => -1, 'conditions'=>array('id'=>$data['id'])));
+ if (!$product) {
+ return false;
+ }
+ $lineItem['Product'] = array_merge($data, $product[$this->controller->modelClass]);
+ } else {
+ // @TODO If statement seems useless, $lineItem is never used before it is overwritten
+ if ($this->Session->check('Order.LineItem.' . $data)) {
+ $lineItem = $this->Session->read('Order.LineItem.' . $data);
+ } else {
+ $product = $this->controller->{$this->controller->modelClass}->find('first', array('recursive' => -1, 'conditions'=>array('id'=>$data)));
+ if (!$product) {
+ return false;
+
+ }
+ $lineItem['Product'] = $product['Product'];
+ }
+ }
+ } else {
+ $lineItem['Product'] = $product = $data;
+ }
+
+
+ // Get the list of line items in the cart
+ $lineItems = array();
+ if ($this->Session->check('Order.LineItem')) {
+ $lineItems = $this->Session->read('Order.LineItem');
+ }
+
+
+ // Check to see if the item is already in the cart
+ if(!empty($lineItems[$lineItem['Product']['id']])) {
+ // The item already exists, just edit it
+ $match = null;
+ foreach($lineItems[$lineItem['Product']['id']]['Selection'] as $count => $selection) {
+ if ($selection['attributes'] == $attribs) {
+ $match = $count;
+ }
+ }
+
+ if ($match !== null) {
+ $quantity = $lineItems[$lineItem['Product']['id']]['Selection'][$match]['quantity'] += $quantity;
+ $returnValue = $this->updateItem($lineItem['Product']['id'], $match, $quantity);
+ } else {
+ $returnValue = $this->_addItemNew($lineItem, $attribs, $quantity, $lineItems);
+ }
+ } else {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $returnValue = $this->_addItemNew($lineItem, $attribs, $quantity, $lineItems);
+ }
+
+
+ return $returnValue;
+ }
+
+
+ /**
+ * Private method to avoid code duplication. Used in $this->addItem()
+ *
+ * @param $lineItem
+ * @param $attribs
+ * @param $quantity
+ * @param $lineItems
+ * @return <success> boolean
+ * @access protected
+ */
+ function _addItemNew($lineItem, $attribs = array(), $quantity, $lineItems) {
+ // Apply LineItem specific attributes
+ $selection = array();
+ // @TODO name and description to be removed from data array?
+ $selection['name'] = $lineItem['Product'][$this->nameField];
+ $selection['price'] = $lineItem['Product'][$this->priceField];
+ // @TODO code needs to be updated to cake compatible standards
+ $selection['description'] = ($this->descField) ? $lineItem['Product'][$this->descField] : null;
+ $selection['taxable'] = ($this->taxableField) ? $lineItem['Product'][$this->taxableField] : true;
+ $selection['quantity'] = $quantity;
+ $selection['subtotal'] = $quantity * $selection['price'];
+ $selection['attributes'] = $attribs;
+
+ // Add the item to the main list
+ $lineItem['Selection'][] = $selection;
+ $lineItems[$lineItem['Product']['id']] = $lineItem;
+
+ $returnValue = $this->Session->write("Order.LineItem", $lineItems);
+ $this->calcTotal();
+
+ return $returnValue;
+ }
+
+ /**
+ * Updates a specific cart item. If quantity is passed at 0 or less, item is deleted.
+ * If $product information is passed, the Product array is updated (does not change lineItem price)
+ * @TODO: I am unsure if I should have multiple actions perform at once (product info + quantity + price).
+ *
+ * @param int $id LineItem id number
+ * @param int $quantity
+ * @param array $product LineItem Product array
+ * @return <success> boolean
+ * @access public
+ */
+ // @TODO $selectionCount is used for...?
+ function updateItem($id, $selectionCount, $quantity = false, $product = null) {
+ $returnValue = null;
+
+
+ // @TODO Handle the $product parameter
+/* if (!empty($product)) {
+ $returnValue = $this->Session->write("Order.LineItem.$id.Product", $product);
+
+ }*/
+
+ if ($quantity <= 0) {
+ // @TODO $selection is undeclared at this point.
+ $returnValue = $this->removeItem($id, $selection);
+ }
+ if ($quantity) {
+ $selection = $this->Session->read("Order.LineItem.$id.Selection");
+
+
+ $selection[$selectionCount]['subtotal'] = $quantity * $selection[$selectionCount]['price'];
+ $selection[$selectionCount]['quantity'] = $quantity;
+
+
+ $returnValue = $this->Session->write("Order.LineItem.$id.Selection", $selection);
+ }
+
+
+ $this->calcTotal();
+ return $returnValue;
+ }
+
+
+ /**
+ * Removes a LineItem from the shopping cart
+ *
+ * @param int $id LineItem id number
+ * @return <success> boolean
+ * @access public
+ */
+ // @TODO Update removeItem to work with selections
+ function removeItem($id, $selection = null) {
+ $returnValue = $this->Session->delete("Order.LineItem.$id");
+ $this->calcTotal();
+
+
+ return $returnValue;
+ }
+
+
+ /**
+ * Returns the Order information for checkout
+ *
+ * @param
+ * @return array() Returns the currently stored shopping cart session with calculations
+ * @access public
+ */
+ function getOrderDetails() {
+ if ($this->Session->check('Order')) {
+ return $this->Session->read('Order');
+ } else {
+ return false;
+ }
+ }
+
+
+ /*
+ * The setPaymentInfo function is a wrapper function to simply fill in both
+ * shipping and billing information at once. If only $billingData is passed
+ * it is copied over to shipping.
+ *
+ * @param array $billingData
+ * @param array $shippingData
+ * @return void
+ * @access public
+ */
+ function setPaymentInfo($billingData, $shippingData = null) {
+ $this->setBillInfo($billingData);
+
+
+ if ($shippingData) {
+ $this->setShipInfo($shippingData);
+ } else {
+ $this->setShipInfo($billingData);
+ }
+ }
+
+
+ /**
+ * Stores the customer billing address info
+ *
+ * @param array $data
+ * @return <success> boolean
+ * @access public
+ */
+ function setBillInfo($data) {
+ return $this->Session->write('Order.Billing', $data);
+ }
+
+
+ /**
+ * Stores the customer shipping address info
+ *
+ * @param array $data
+ * @return <success> boolean
+ * @access public
+ */
+ function setShipInfo($data) {
+ return $this->Session->write('Order.Shipping', $data);
+ }
+
+
+ /**
+ * Checks to make sure tax rate is a decimal and stores for use in calcTotal()
+ *
+ * @param decimal $taxRate
+ * @return void
+ * @access public
+ */
+ function setTaxRate($taxRate) {
+ // Ensures that percent values are changed to decimal
+ if ($taxRate > 1)
+ $taxRate = $taxRate / 100;
+
+
+ $this->taxRate = $taxRate;
+ $this->calcTotal();
+ }
+
+
+ /**
+ * Checks to make sure shipping rate is a decimal if it's not a flat fee and
+ * stores for use in calcTotal()
+ *
+ * @param decimal $shipRate
+ * @param boolean $flat Wether or not the shipping rate is a flat fee
+ * @return void
+ * @access public
+ */
+ function setShipRate($shipRate, $flat = true) {
+ // Ensures that percent values are changed to decimal
+ if (!$flat && $shipRate > 1)
+ $shipRate = $shipRate / 100;
+
+
+ $this->shipRate = $shipRate;
+ $this->calcTotal();
+ }
+
+
+ /**
+ * Conveniance method for handling all shipping in one call
+ *
+ * @param decimal $price
+ * @param boolean $info
+ * @return void
+ * @access public
+ */
+ function setShipping($price, $info) {
+ $this->setShipRate($price);
+ $this->setShipInfo($info);
+ }
+
+
+ /**
+ * This function takes the order out of the session, goes row by row totalling up
+ * the prices into $subtotal, applying tax to individual products that are taxable = true,
+ * and then adds it all together, including shipping, which it stores back into the
+ * Order session under Order.Totals
+ *
+ * @return <success> boolean
+ * @access public
+ */
+ function calcTotal() {
+ $order = $this->Session->read('Order');
+ $subtotal = 0;
+
+
+ foreach ($order['LineItem'] as $id => $lineItem) {
+
+ $lineQuantity = 0;
+ $lineTotal = 0;
+ foreach ($lineItem['Selection'] as $count => $selection) {
+ $selectionTotal = $selection['price'] * $selection['quantity'];
+ // @TODO create a way to tax indidividual products vs all products
+/* if ($selection['taxable'])
+ $selectionTotal += $selectionTotal * $this->taxRate;*/
+ $subtotal += $selectionTotal;
+
+ $lineQuantity += $selection['quantity'];
+ $lineTotal += $selectionTotal;
+ }
+
+ $totals = array(
+ 'quantity' => $lineQuantity,
+ 'subtotal' => $lineTotal,
+ );
+
+ $this->Session->write('Order.LineItem.' . $id . '.Totals', $totals);
+ }
+
+ // @TODO create a way to tax indidividual products vs all products
+ $tax = sprintf('%.2f', $subtotal * $this->taxRate);
+ // @TODO needs to be converted to cake acceptable coding standards
+ $shipping = ($this->shipFlat) ? $this->shipRate : $subtotal * $this->shipRate;
+ $total = $subtotal + $tax + $shipping;
+
+
+ $data = array(
+ 'subtotal' => $subtotal,
+ 'tax' => $tax,
+ 'shipping' => $shipping,
+ 'total' => $total,
+ );
+
+
+ return $this->Session->write('Order.Totals', $data);
+ }
+
+
+}
+?>
View
14 models/cart_product.php
@@ -0,0 +1,14 @@
+<?php
+class CartProduct extends CartAppModel {
+
+ var $name = 'CartProduct';
+ var $validate = array(
+ 'name' => array('notempty'),
+ 'taxable' => array('boolean'),
+ 'price' => array('decimal'),
+ 'visible' => array('boolean'),
+ 'active' => array('boolean')
+ );
+
+}
+?>
View
26 tests/cases/controllers/cart_products_controller.test.php
@@ -0,0 +1,26 @@
+<?php
+/* SVN FILE: $Id$ */
+/* CartProductsController Test cases generated on: 2009-07-21 14:07:21 : 1248210381*/
+App::import('Controller', 'Cart.CartProducts');
+
+class TestCartProducts extends CartProductsController {
+ var $autoRender = false;
+}
+
+class CartProductsControllerTest extends CakeTestCase {
+ var $CartProducts = null;
+
+ function startTest() {
+ $this->CartProducts = new TestCartProducts();
+ $this->CartProducts->constructClasses();
+ }
+
+ function testCartProductsControllerInstance() {
+ $this->assertTrue(is_a($this->CartProducts, 'CartProductsController'));
+ }
+
+ function endTest() {
+ unset($this->CartProducts);
+ }
+}
+?>
View
37 tests/cases/models/cart_product.test.php
@@ -0,0 +1,37 @@
+<?php
+/* SVN FILE: $Id$ */
+/* CartProduct Test cases generated on: 2009-07-21 14:07:10 : 1248210310*/
+App::import('Model', 'Cart.CartProduct');
+
+class CartProductTestCase extends CakeTestCase {
+ var $CartProduct = null;
+ var $fixtures = array('plugin.cart.cart_product');
+
+ function startTest() {
+ $this->CartProduct =& ClassRegistry::init('CartProduct');
+ }
+
+ function testCartProductInstance() {
+ $this->assertTrue(is_a($this->CartProduct, 'CartProduct'));
+ }
+
+ function testCartProductFind() {
+ $this->CartProduct->recursive = -1;
+ $results = $this->CartProduct->find('first');
+ $this->assertTrue(!empty($results));
+
+ $expected = array('CartProduct' => array(
+ 'id' => 1,
+ 'created' => '2009-07-21 14:05:10',
+ 'modified' => '2009-07-21 14:05:10',
+ 'name' => 'Lorem ipsum dolor sit amet',
+ 'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida,phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam,vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit,feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
+ 'taxable' => 1,
+ 'price' => 1,
+ 'visible' => 1,
+ 'active' => 1
+ ));
+ $this->assertEqual($results, $expected);
+ }
+}
+?>
View
32 tests/fixtures/cart_product_fixture.php
@@ -0,0 +1,32 @@
+<?php
+/* SVN FILE: $Id$ */
+/* CartProduct Fixture generated on: 2009-07-21 14:07:10 : 1248210310*/
+
+class CartProductFixture extends CakeTestFixture {
+ var $name = 'CartProduct';
+ var $table = 'cart_products';
+ var $fields = array(
+ 'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
+ 'created' => array('type'=>'datetime', 'null' => false, 'default' => NULL),
+ 'modified' => array('type'=>'datetime', 'null' => false, 'default' => NULL),
+ 'name' => array('type'=>'string', 'null' => false, 'default' => NULL, 'length' => 128),
+ 'description' => array('type'=>'text', 'null' => false, 'default' => NULL),
+ 'taxable' => array('type'=>'boolean', 'null' => false, 'default' => NULL),
+ 'price' => array('type'=>'float', 'null' => false, 'default' => NULL, 'length' => '10,2'),
+ 'visible' => array('type'=>'boolean', 'null' => false, 'default' => NULL),
+ 'active' => array('type'=>'boolean', 'null' => false, 'default' => NULL),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
+ );
+ var $records = array(array(
+ 'id' => 1,
+ 'created' => '2009-07-21 14:05:10',
+ 'modified' => '2009-07-21 14:05:10',
+ 'name' => 'Lorem ipsum dolor sit amet',
+ 'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida,phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam,vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit,feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
+ 'taxable' => 1,
+ 'price' => 1,
+ 'visible' => 1,
+ 'active' => 1
+ ));
+}
+?>
View
20 views/cart_products/add.ctp
@@ -0,0 +1,20 @@
+<div class="cartProducts form">
+<?php echo $form->create('CartProduct');?>
+ <fieldset>
+ <legend><?php __('Add CartProduct');?></legend>
+ <?php
+ echo $form->input('name');
+ echo $form->input('description');
+ echo $form->input('taxable');
+ echo $form->input('price');
+ echo $form->input('visible');
+ echo $form->input('active');
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('List CartProducts', true), array('action'=>'index'));?></li>
+ </ul>
+</div>
View
22 views/cart_products/edit.ctp
@@ -0,0 +1,22 @@
+<div class="cartProducts form">
+<?php echo $form->create('CartProduct');?>
+ <fieldset>
+ <legend><?php __('Edit CartProduct');?></legend>
+ <?php
+ echo $form->input('id');
+ echo $form->input('name');
+ echo $form->input('description');
+ echo $form->input('taxable');
+ echo $form->input('price');
+ echo $form->input('visible');
+ echo $form->input('active');
+ ?>
+ </fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value('CartProduct.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('CartProduct.id'))); ?></li>
+ <li><?php echo $html->link(__('List CartProducts', true), array('action'=>'index'));?></li>
+ </ul>
+</div>
View
76 views/cart_products/index.ctp
@@ -0,0 +1,76 @@
+<div class="cartProducts index">
+<h2><?php __('CartProducts');?></h2>
+<p>
+<?php
+echo $paginator->counter(array(
+'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
+));
+?></p>
+<table cellpadding="0" cellspacing="0">
+<tr>
+ <th><?php echo $paginator->sort('id');?></th>
+ <th><?php echo $paginator->sort('created');?></th>
+ <th><?php echo $paginator->sort('modified');?></th>
+ <th><?php echo $paginator->sort('name');?></th>
+ <th><?php echo $paginator->sort('description');?></th>
+ <th><?php echo $paginator->sort('taxable');?></th>
+ <th><?php echo $paginator->sort('price');?></th>
+ <th><?php echo $paginator->sort('visible');?></th>
+ <th><?php echo $paginator->sort('active');?></th>
+ <th class="actions"><?php __('Actions');?></th>
+</tr>
+<?php
+$i = 0;
+foreach ($cartProducts as $cartProduct):
+ $class = null;
+ if ($i++ % 2 == 0) {
+ $class = ' class="altrow"';
+ }
+?>
+ <tr<?php echo $class;?>>
+ <td>
+ <?php echo $cartProduct['CartProduct']['id']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['created']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['modified']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['name']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['description']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['taxable']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['price']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['visible']; ?>
+ </td>
+ <td>
+ <?php echo $cartProduct['CartProduct']['active']; ?>
+ </td>
+ <td class="actions">
+ <?php echo $html->link(__('View', true), array('action'=>'view', $cartProduct['CartProduct']['id'])); ?>
+ <?php echo $html->link(__('Edit', true), array('action'=>'edit', $cartProduct['CartProduct']['id'])); ?>
+ <?php echo $html->link(__('Delete', true), array('action'=>'delete', $cartProduct['CartProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $cartProduct['CartProduct']['id'])); ?>
+ </td>
+ </tr>
+<?php endforeach; ?>
+</table>
+</div>
+<div class="paging">
+ <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?>
+ <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('New CartProduct', true), array('action'=>'add')); ?></li>
+ </ul>
+</div>
View
58 views/cart_products/view.ctp
@@ -0,0 +1,58 @@
+<div class="cartProducts view">
+<h2><?php __('CartProduct');?></h2>
+ <dl><?php $i = 0; $class = ' class="altrow"';?>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['id']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['created']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Modified'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['modified']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['name']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Description'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['description']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Taxable'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['taxable']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Price'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['price']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Visible'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['visible']; ?>
+ &nbsp;
+ </dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Active'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <?php echo $cartProduct['CartProduct']['active']; ?>
+ &nbsp;
+ </dd>
+ </dl>
+</div>
+<div class="actions">
+ <ul>
+ <li><?php echo $html->link(__('Edit CartProduct', true), array('action'=>'edit', $cartProduct['CartProduct']['id'])); ?> </li>
+ <li><?php echo $html->link(__('Delete CartProduct', true), array('action'=>'delete', $cartProduct['CartProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $cartProduct['CartProduct']['id'])); ?> </li>
+ <li><?php echo $html->link(__('List CartProducts', true), array('action'=>'index')); ?> </li>
+ <li><?php echo $html->link(__('New CartProduct', true), array('action'=>'add')); ?> </li>
+ </ul>
+</div>
View
20 views/helpers/cart.php
@@ -0,0 +1,20 @@
+<?php
+class CartHelper extends AppHelper {
+ var $helpers = array('Html', 'Form', 'Session');
+
+ function renderCart() {
+ $result = null;
+
+ if ($this->Session->check('Order')) {
+ debug($this->Session->read('Order'));
+ $result = true;
+ }
+
+ return $result;
+ }
+
+ function makeEdit($title, $url) {
+ // Logic to create specially formatted link goes here...
+ }
+}
+?>

0 comments on commit 601e268

Please sign in to comment.
Something went wrong with that request. Please try again.