Totally Zenned
- Join Date:
- Mar 2009
- Posts:
- 616
- Plugin Contributions:
- 0
Twitch Restrict Categories by Customer or Group
Is this something you can add to the base code or are you doing this as a custom job?
Views: 25,391
Totally Zenned
Is this something you can add to the base code or are you doing this as a custom job?
Totally Zenned
DigitalShadow:
Is this something you can add to the base code or are you doing this as a custom job?
This would be a custom job. Ideally in the future I'd love to have 'insertion switches' in admin where you could control where various access points become available!
Totally Zenned
Has anyone gotten this to work with drop down menus? If you did can you please post the before and after code you used to filter out the restricted categories?
Totally Zenned
Ok I was able to figure it out myself but if there are any coders that verify my code that would be appreciated.
I modified the following file to get it to work with module "CSS Flyout Menu" /includes/classes/categories_ul_generator.php
Before:
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
" order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
After:
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_CUSTOMERS . " ccu, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
AND c.categories_id = ccu.categories_id
AND (ccu.customers_cat_group = '" . (int)$_SESSION['customers_cat_group'] . "' OR ccu.customers_cat_group = '0' )
order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
Zen Follower
Any thoughts on getting this working on zencart 1.5.5?
Totally Zenned
This module is working great but I'm having an issue on all the product pages (products_all, products_new, specials, featured_products). After doing the following adjustment to the header_php.php file (as instructions):
*****
includes/modules/pages/products_all/header_php.php
*****
change lines 23 - 34 from this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
// bof dynamic filter 1 of 1
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_DYNAMIC_FILTER));
$listing_sql = "SELECT DISTINCT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight,
p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status, p.master_categories_id, m.manufacturers_id";
$listing_sql .= " FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id)" .
" left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id" .
" left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id" .
($filter_attr == true ? " join " . TABLE_PRODUCTS_ATTRIBUTES . " p2a on p.products_id = p2a.products_id" .
" join " . TABLE_PRODUCTS_OPTIONS . " po on p2a.options_id = po.products_options_id" .
" join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on p2a.options_values_id = pov.products_options_values_id" .
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as on p.products_id = p2as.products_id " : "") : '');
$listing_sql .= " WHERE p.products_status = 1 AND (p.products_date_available IS NULL OR p.products_date_available <= current_date) AND pd.language_id = :languageID " .
$filter . " GROUP BY p.products_id " . $having . $order_by;
$listing_sql = $db->bindVars($listing_sql, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_ALL);
// eof dynamic filter 1 of 1
to this:
$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id),
"
. TABLE_PRODUCTS_TO_CATEGORIES . " p2c
LEFT JOIN " . TABLE_CATEGORIES_CUSTOMERS . " ccu
on p2c.categories_id = ccu.categories_id,
" . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID
AND p.products_id = p2c.products_id
AND p2c.categories_id = ccu.categories_id
AND (ccu.customers_cat_group = '" . (int)$_SESSION['customers_cat_group'] . "' OR ccu.customers_cat_group = '0' )
" . $order_by;
$products_all_query_raw = $db->bindVars($products_all_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($products_all_query_raw, MAX_DISPLAY_PRODUCTS_ALL);
The pages start to do few things incorrect:
-displays incorrect number of items listed (instead of decreasing the number this one goes up from 635 to 666);
-repeats items (I think this is why it increases the number of items);
-messes up the styling of the pages (very bad), this is probably the easiest issue of all to fix since it could be related to the template's grid and css.
That file section (and the other product pages headers) was already altered to this:
// bof dynamic filter 1 of 1
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_DYNAMIC_FILTER));
$listing_sql = "SELECT DISTINCT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight,
p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status, p.master_categories_id, m.manufacturers_id";
$listing_sql .= " FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id)" .
" left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id" .
" left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id" .
($filter_attr == true ? " join " . TABLE_PRODUCTS_ATTRIBUTES . " p2a on p.products_id = p2a.products_id" .
" join " . TABLE_PRODUCTS_OPTIONS . " po on p2a.options_id = po.products_options_id" .
" join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on p2a.options_values_id = pov.products_options_values_id" .
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as on p.products_id = p2as.products_id " : "") : '');
$listing_sql .= " WHERE p.products_status = 1 AND (p.products_date_available IS NULL OR p.products_date_available <= current_date) AND pd.language_id = :languageID " .
$filter . " GROUP BY p.products_id " . $having . $order_by;
$listing_sql = $db->bindVars($listing_sql, ':languageID', $_SESSION['languages_id'], 'integer');
$products_all_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_ALL);
// eof dynamic filter 1 of 1
Please, let me know how I am supposed to change this portion for it to work properly.
Totally Zenned
ideasgirl what version of ZC and template are you working with?
Totally Zenned
mattys:
Any thoughts on getting this working on zencart 1.5.5?
1.55f - Yes.
Totally Zenned
marcopolo:
Has anyone gotten this to work with drop down menus? If you did can you please post the before and after code you used to filter out the restricted categories?
First, I would need to see the code for the drop down you speak of.
Second, most of the existing filters will work but may need to be customized to work with your particular menu code.
Totally Zenned
twitchtoo:
ideasgirl what version of ZC and template are you working with?
1.5.5f
The issues were solved.
Zen Follower
Thank you for the great add-on.
I have having an issue with the new product & featured page. I have set up as a single product linked to multiple categories. For example if an item 1TW is linked to 3 categories and if I set it item a featured then I see that on the featured page this item is displayed three times. The page works fine if the item is only set to one category.
After looking in to the codes( I am not a good programmer) found that includes/pages/featured/header_php.php has the code. How do I make change in the query to take only one one row instead of three rows from TABLE_PRODUCTS_TO_CATEGORIES?
$featured_products_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call, p.product_is_always_free_shipping,
p.products_qty_box_status, p.master_categories_id
FROM ("
. TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
on (p.manufacturers_id = m.manufacturers_id),
"
. TABLE_PRODUCTS_DESCRIPTION . " pd
LEFT JOIN " . TABLE_FEATURED . " f
on pd.products_id = f.products_id,
"
. TABLE_PRODUCTS_TO_CATEGORIES . " p2c
LEFT JOIN " . TABLE_CATEGORIES_CUSTOMERS . " ccu
on p2c.categories_id = ccu.categories_id
)
WHERE p.products_status = 1
and p.products_id = f.products_id
and f.status = 1
AND p.products_id = pd.products_id
and pd.language_id = :languagesID
AND p.products_id = p2c.products_id
AND (ccu.customers_cat_group = '" . (int)$_SESSION['customers_cat_group'] . "' OR ccu.customers_cat_group = '0' )
" . $order_by;
Thanks so much for any help!
Zen Follower
Just wondering if this module is being upgraded to 1.5.7? :-)
Zen Follower
This is not working for 1.5.6. In admin/categories.php file codes are very different. Do you have updated version of this?
Totally Zenned
Here's another person who would really like this to work with 1.5.6 and up.
Totally Zenned
This module is being included in the next release of Twitch Wholesale PRO Public/Commercial for ZC 1.56c as the Twitch Bridge Matrix now handles product and category level relationships with customer groups using the new wsPRO Manager in Admin.
Release is pending imminently for Zen Cart 1.56c and will be next on the list for development into ZC 1.57c when funding/donations afford it.
Thanks for your support!
Zen Follower
Thank you for the great mod.
I am having an issue with this module in the mobile version.
1)
The sidebox categories box displays all the categories if a customer is not logged in. I want to hide the sidebox category when the customer is not logged in on mobile. Works fine on the Desktop version.
Did anyone solve this issue? I have picture attached to show this. The first two categories are only for a specific group.
Thanks
Tell staff why this post should be reviewed.