Updates to the store module.

git-svn-id: http://svn.cleancode.org/svn/pickles@88 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
Josh Sherman 2009-02-05 03:40:21 +00:00
parent 7c199b56dd
commit 1bed8270ea
2 changed files with 16 additions and 4 deletions

View file

@ -1,5 +1,14 @@
<?php
/**
* Store
*
* @package PICKLES
* @subpackage store
* @author Joshua Sherman <josh@phpwithpickles.org>
* @copyright 2007-2009 Joshua Sherman
*/
class store extends Module {
protected $display = DISPLAY_SMARTY;
@ -28,7 +37,9 @@ class store extends Module {
$this->cart = $_SESSION['cart'];
// Loads the navigation
$this->subnav = $config->store->sections;
if (isset($config->store->sections)) {
$this->subnav = $config->store->sections;
}
// Loads the categories
$categories = $this->db->getArray('SELECT id, name, permalink FROM categories WHERE parent_id IS NULL AND visible = "Y" ORDER BY weight;');

View file

@ -8,7 +8,7 @@
* @package PICKLES
* @subpackage store
* @author Joshua Sherman <josh@phpwithpickles.org>
* @copyright 2007-2008 Joshua Sherman
* @copyright 2007-2009 Joshua Sherman
*/
class store_cart_add extends store {
@ -34,8 +34,9 @@ class store_cart_add extends store {
}
// Increment the quantity and update the total
$product['quantity']++;
$product['total'] = round($product['price'] * $product['quantity'], 2);
$increment = preg_match('/^[0-9]+$/', $_REQUEST['quantity']) && trim($_REQUEST['quantity']) != '' ? $_REQUEST['quantity'] : 1;
$product['quantity'] += $increment;
$product['total'] = round($product['price'] * $product['quantity'], 2);
unset($product);
// References the cart as a whole