|
Question : Add products to first level category From : Benjamin I would like to add products to the first level category, how would I do this? Thanks, Benjamin Answer I'm afraid that is not possible without modifying the code since the original design was that all products are added on the second level category. To add a product on the first level category you will need to modify the buildCategoryOptions() function in admin/library/functions.php. Replace the old function code with this one : function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= " if ($key == $catId) { $list.= " selected"; } $list .= ">$name\r\n"; foreach ($children as $child) { $list .= " if ($child['id'] == $catId) { $list.= " selected"; } $list .= "> {$child['name']}\r\n"; } } return $list; }
|
|
|
|
|
Q & A | PHP MySQL Shopping Cart Tutorial : Q & A - Detail |
At long last i'm finally able to update this site. Now the shopping cart can handle payment through paypal. As always you have any critiques, questions, comments or problems about this tutorial please tell me. Click here to send your feedback. And if you like this tutorial please link to this site. It will really help a lot :-) |
Copyright © 2005 - 2008 www.phpwebcommerce.com