get_results("SELECT DISTINCT `price` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE `active` IN ('1') ORDER BY price ASC",ARRAY_A);
if($result != null) {
sort($result);
$count = count($result);
$price_seperater = ceil($count/6);
for($i=0;$i<$count;$i+=$price_seperater) {
$ranges[]=round($result[$i]['price'],-1);
}
$ranges = array_unique($ranges);
$final_count = count($ranges);
$ranges = array_merge(array(), $ranges);
$_SESSION['price_range']=$ranges;
// echo(''.print_r($ranges, true).'
');
for($i=0;$i<$final_count;$i++) {
$j=$i;
if ($i==$final_count-1) {
echo "Over ".$ranges[$i]."
";
} else if($ranges[$i]==0){
echo "Under ".$ranges[$i+1]."
";
}else {
echo "".$ranges[$i]." - ".$ranges[$i+1]."
";
}
}
if(get_option('permalink_structure') != '') {
$seperator ="?";
} else {
$seperator ="&";
}
echo "".TXT_WPSC_SHOWALL."
";
}
}
function widget_price_range_control() {
$option_name = 'wpsc-widget_price_range'; // because I want to only change this to reuse the code.
$options = $newoptions = get_option($option_name);
if ( isset($_POST[$option_name]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST[$option_name]));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option($option_name, $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
echo "\n\r";
echo " \n\r";
echo "
\n\r";
}
function widget_price_range_init() {
if(function_exists('register_sidebar_widget')) {
register_sidebar_widget(TXT_WPSC_PRICE_RANGE, 'widget_price_range');
register_widget_control(TXT_WPSC_PRICE_RANGE, 'widget_price_range_control');
}
return;
}
add_action('plugins_loaded', 'widget_price_range_init');
?>