Totally Zenned
- Join Date:
- Dec 2009
- Location:
- Amersfoort, The Netherlands
- Posts:
- 2,862
- Plugin Contributions:
- 5
Dynamic Filter [Support Thread]
RodG:
This may help (changes in blue) :
// File /modules/custom/dynamic_filter.php
/ Price Range/Attribute filter
$manufacturerGroup = str_replace(' ', '', DYNAMIC_FILTER_MANUFACTURER_GROUP);
$categoryGroup = str_replace(' ', '', DYNAMIC_FILTER_CATEGORY_GROUP);
$priceGroup = str_replace(' ', '', DYNAMIC_FILTER_PRICE_GROUP);
$prvKey = '';
$prvHaving = '';
$filter = '';
$having = '';
$filter_attr = false;reset($_GET);
while(list($key, $value) = each ($_GET)) {
// if(!is_array($value)) { // skip if not array // RodGif(substr($key,0,strlen(DYNAMIC_FILTER_PREFIX)) == DYNAMIC_FILTER_PREFIX && array_filter($value)) { $key = str_replace(DYNAMIC_FILTER_PREFIX, '', $key); foreach ($value as $value) { if($key == $manufacturerGroup || $key == $categoryGroup || $key == $priceGroup) { if($key != $prvKey) { if($prvKey != '') { $filter .= ') and ('; } else { $filter .= ' and ('; } } else { $filter .= ' or '; } } // manufacturer if($key == $manufacturerGroup) { $filter .= "m.manufacturers_id = '" . (int)$value . "'"; $prvKey = $key; // category } else if($key == $categoryGroup) { $filter .= "p2c.categories_id = '" . (int)$value . "'"; $prvKey = $key; // price range } else if($key == $priceGroup) { list($low,$high) = explode("--",$value); // Updated to include GST by RodG$filter .= 'p.products_price_sorter>=' . ($low - ($low / 11)) . ' and ' . 'p.products_price_sorter<=' . ($high - ($high / 11));
// $filter .= 'p.products_price_sorter>=' . $low . ' and ' . 'p.products_price_sorter<=' . $high; // original code //
$prvKey = $key;
// attributes
} else {
if($key != $prvHaving) {
if($prvHaving != '') {
$having .= ') and (';
} else {
$having .= 'HAVING (';
}
} else {
$having .= ' or ';
}
$having .= ' FIND_IN_SET("' . $key . $value . '", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))';
$filter_attr = true;
$prvHaving = $key;
}
}
}
//}
}
if($filter != '') $filter .= ')';
if($having != '') $having .= ')';
if($filter_attr == true && defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK')) $filter .= ' AND p2as.quantity > 0 AND FIND_IN_SET(p2a.products_attributes_id, p2as.stock_attributes)';
OK, so it isn't going to be exactly what you want. This was a quick n dirty fix I added to a customers site to account for a 10% GST.
It shouldn't be hard to replace these hard coded calculations with variables obtained from the Tax tables though.Cheers
RodG
Thx, I'll go and test it right away.