connect(); // Check to see if Category is in db if ($db->count('categories','name="'.$c.'"') == 0) redirect(); // HTML $PAGE_HEADING = ''; $PAGE_CONTENT = ''; // Retrieve Items $init_items = $db->select( 'items.itemID,items.stock,SUM(carts.quantity) AS quantity', 'items,categories LEFT JOIN carts ON (items.itemID=carts.itemID)', 'categories.name="'.$c.'" AND categories.categoryID=items.categoryID AND items.status="Available" AND items.stock > 0', '', 'GROUP BY items.itemID ORDER BY items.itemID DESC'); $items = array(); foreach ($init_items as $item) { if ($item['stock'] > $item['quantity']) $items[] = $item; } if (count($items) > 0) { foreach ($items as $prod) { $item = new Item($prod['itemID']); // Determine file path of thumbnail for product $thumb_path = _IMAGE_DIR._THUMB_DIR.$item->image1; // Check if file exists if (file_exists($thumb_path)) $thumb = _IMAGE_URL._THUMB_DIR.$item->image1; // If not use missing image else $thumb = _SITE_URL.'images/no_image.gif'; if ($unavailable == $item->id) { if (rq('det')) { $missing_fields = array(); $db_missing_fields = $db->select('field_default','schemaFields','fieldID IN ('.rq('det').')','list_order'); foreach ($db_missing_fields as $missing_field) $missing_fields[] = $missing_field['field_default']; $unv_msg = '
This item is not available in a '.implode(' | ',$missing_fields).' combination
'; } } else $unv_msg = ''; // Compile item button paths $button1 = _SITE_URL.'images/buttons/btn_add2cart.gif'; $button2 = _SITE_URL.'images/buttons/btn_checkout.gif'; $short_desc = $item->getShortDesc(); $PAGE_CONTENT .= <<
{$item->name}
{$item->name} View item details
{$unv_msg}
{$short_desc}
HTML; // Get item Details from db $schema_fields = $item->getSchemaFields(); foreach ($schema_fields as $schema_field) { switch ($schema_field['type']) { case 'select': // Select other fields $fields = $item->getAvailableFields($schema_field['name'],$schema_field['type']); $PAGE_CONTENT .= '
'.$schema_field['name'].' 
'; break; } } $PAGE_CONTENT .= <<Price: \${$item->price} (AUD)
Proceed to Checkout
HTML; } $PAGE_CONTENT .= '
* All prices include GST.
'; } else $PAGE_CONTENT .= "Sorry, there are no items available items in this category."; // Assign template vars $t->assign_vars(array('PAGE_HEADING' => $PAGE_HEADING, 'PAGE_CONTENT' => $PAGE_CONTENT)); // Parse template $t->pparse('main'); ?>