show zencart categories/products in WordPress main or sidebar
-
After days of intensive searching I have only found one website offering a solution to displaying Zencart items inside a WordPress page.
I don’t want to use the WordPress on Zencart plugin. I want an existing WordPress website, which is used as a CMS, to display some or all of the products available in the Zen Cart shop.
I found a possible solution here, I can’t get it working but I think it is possibly a simple problem to do with the ‘DEFINE’.
I’m hoping someone here can explain the links needed in the DEFINEs- I & 2 others get the same error message “Parse error: syntax error, unexpected ‘:’ in /home/noah/public_html/blog/wp-content/plugins/zencat/zencat.php on line 13”
Line 13 is the either the third or 4th DEFINE
“define(‘DIR_WS_CATALOG’, ‘/~lsenft/zencart/’);
define(‘HTTP_SERVER’, ‘https://localhost’);”My WordPress installation is in public_html and Zencart is in public_html/shop – what should I put in the defines?
Below is the entire code which when saved in the plugins folder as a php file creates a plugin called Products
<?php /* Plugin Name: Products Plugin URI: https://www.levisenft.com/ Description: Zen Cart Categories Author: Levi Senft Version: 1 Author URI: https://www.levisenft.com/ */ define(‘TABLE_CATEGORIES’, ‘zen_categories’); define(‘TABLE_CATEGORIES_DESCRIPTION’, ‘zen_categories_description’); define(‘DIR_WS_CATALOG’, ‘/~lsenft/zencart/’); define(‘HTTP_SERVER’, ‘https://localhost’); function zen_cat() { echo ‘<li class="widget widget_zen_cat"><h2 class="widgettitle">Products</h2><ul>’; $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = 0 and c.categories_id = cd.categories_id and c.categories_status= 1 order by sort_order, cd.categories_name"; $results = mysql_query($categories_query); $item_count = 1; while($row = mysql_fetch_assoc($results)) { echo ‘<li class="zen_cat_item zen-cat-item-’ . $item_count . ‘"><a href="’ . HTTP_SERVER . DIR_WS_CATALOG . ‘index.php?main_page=index&cPath=’ . $row['categories_id'] . ‘">’ . $row['categories_name'] . ‘</a>’; $subcats_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = " . $row['categories_id'] . " and c.categories_id = cd.categories_id and c.categories_status= 1 order by sort_order, cd.categories_name"; $subcats_results = mysql_query($subcats_query); if (mysql_num_rows($subcats_results) > 0) { $subitem_count = 1; echo ‘<ul>’; while($subcats_row = mysql_fetch_assoc($subcats_results)) { echo ‘<li class="zen_cat_item zen-cat-item-’ . $subitem_count . ‘"><a href="’ . HTTP_SERVER . DIR_WS_CATALOG . ‘index.php?main_page=index&cPath=’ . $row['categories_id'] . ‘_’ . $subcats_row['categories_id'] . ‘">’ . $subcats_row['categories_name'] . ‘</a>’; $subitem_count++; } echo ‘</ul>’; } echo ‘</li>’; $item_count++; } echo ‘</ul></li>’; } function init_zen_cat(){ register_sidebar_widget("Products", "zen_cat"); } add_action("plugins_loaded", "init_zen_cat"); ?>
- The topic ‘show zencart categories/products in WordPress main or sidebar’ is closed to new replies.