Hi!
I have created a custom category menu using the API. The API returns parent categories and subcategories, but in the wrong order. In other words, the menu items are not returned in the order I have sorted them in Ecwid backend.
Is there a way to get the menu items in the order set?
My code is:
PHP Code:
<?php
include_once "ecwid_product_api.php";
$api = new EcwidProductApi(410495); // initialize the API class. Replace 1003 with your Store ID
?>
<div id="meny">
<div id="ecwid-menu">
<?php
$categories = $api->get_subcategories_by_id($parent_category_id = 0); //get product info by its ID
echo '<ul>';
foreach($categories as $category)
{
echo '<li id="parentitem">';
echo <<<EOT
<a href='{$category["url"]}' style='float: left; width: auto;'>
{$category["name"]}
</a>
EOT;
$subcategories = $api->get_subcategories_by_id($category["id"]); //get product info by its ID
if ($subcategories) {
echo '<ul id="submenu">';
foreach($subcategories as $subcategory)
{
echo <<<EOT
<li id="subitem"><a href='{$subcategory["url"]}'>
{$subcategory["name"]}
</a></li>
EOT;
}echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
?>
</div>
</div>