Force Radio/Grid with Wholesale Filter
I needed to control the switch between display options, in my case 'radio' buttons for guest/retail customers and 'grid' with quantity for wholesale customers.
Here is the code that will force Zen to stop looking at the database options_type > 2 - Radio or > 23997 - Grid. It then relies on the wholesale switch to decide if it should be displaying a radio button or the grid matrix.
Found at the top of includes/modules/YOUR_TEMPLATE/attributes.php
PHP Code:
$pr_attr = $db->Execute($check_attributes_sql);
$check_attributes_count = $pr_attr->RecordCount();
$pr_attr->fields['total'] = $check_attributes_count; //Fix for template checks
$check_grid = false;
while(!$pr_attr->EOF) {
switch($pr_attr->fields['products_options_type']) {
// bof Twitch Force Radio/Grid with Wholesale Filter 1 of 2 May 16 2012
case '2': //GRID exists // Twitch changed '23997' to '2'
// Twitch Wholesale Filter
if($_SESSION['customers_wholesale'] =='' or $_SESSION['customers_wholesale'] !='1'){
$check_grid = false;
} else {
$check_grid = true;
}
// eof Twitch Force Radio/Grid with Wholesale Filter 1 of 2 May 16 2012
break;
}
$pr_attr->MoveNext();
}
$show_only_grid = false;
if ($check_grid) { // when check grid is true - this determines if the grid actually turns on or not
if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
$options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
} else {
$options_order_by= ' order by popt.products_options_name';
}
$sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order, popt.products_options_comment
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
where patrib.products_id='" . (int)$_GET['products_id'] . "'
and patrib.options_id = popt.products_options_id
and popt.products_options_type = '2'
and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
// bof Twitch Force Radio/Grid with Wholesale Filter 2 of 2 May 16 2012
// **** note changed following line: and popt.products_options_type = '2' ***** above to 2 not 23997 - forces it to use the radio buttons by default
// eof Twitch Force Radio/Grid with Wholesale Filter 2 of 2 May 16 2012
IMPORTANT: In the admin section when you navigate to catalog>option name manager you do NOT need to change the option names for your attributes to 'grid', the code above is looking for the radio button switch => option_type = '2' - 'Radio'
Please Note:
This fix is working within a heavily modified ZenCart 1.3.9.h including the following unreleased related modules:
Dual Pricing 1.9t - Twitch Wholesale Pricing
Multi Site
Stock by Attribute w/sold out by attribute patched within the grid matrix
Attributes Grid
And More...
Twitch.
Bookmarks