Jump to content

Plaincart Categories


quasiman

Recommended Posts

I'm trying to allow plaincart to have more than 1 subcategory, but whenever I get to a 2nd sublevel  (level 3) I get this error:

Notice: Undefined index: name in /home/myname/public_html/cart/admin/library/functions.php on line 260

 

Here is the function to build the category menu - I've inserted a comment for line 260

 

function buildCategoryOptions($catId = 1)
{
$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 == 1) {
		// 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) {
// line 260 ->	$name     = $value['name'];
	$children = $value['children'];

	$list .= "<option value=\"$key\"";
	if ($key == $catId) {
		$list.= " selected";
	}

	$list .= ">$name</option>\r\n";

	foreach ($children as $child) {
		$list .= "<option value=\"{$child['id']}\"";
		if ($child['id'] == $catId) {
			$list.= " selected";
		}

		$list .= ">  {$child['name']}</option>\r\n";
	}
}

return $list;
}

Link to comment
https://forums.phpfreaks.com/topic/39766-plaincart-categories/
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.