You are here:  » How to make a drop down list for your price bracket

Support Forum



How to make a drop down list for your price bracket

Submitted by shogounou on Sat, 2008-08-23 12:12 in

Hello everybody

David post has already posted a good price brackets code.

Now I would like to know how to present price brackets in a drop down list

Anybody can help me?

Thank you

Guillaume

Submitted by support on Sat, 2008-08-23 12:20

Hello Guillaume,

Bear with me - i'll look at the code you sent and help you work out how to do this in the same style as the merchant and brand drop-downs...

Cheers,
David.

Submitted by shogounou on Sat, 2008-08-23 12:59

thank you david

Submitted by shogounou on Sat, 2008-08-23 13:28

Hello David

You 're right.
Unfortunately, I am not a developer and my php knowledge and understanding are quite limited.
I post the price brackets code with my try with does not work.

Can you help me in modifying the necessary code, in order to have a drop down list with price brackets.

Thank you Guillaume

<?php
$bracket 
= array(
array(
"number" => "1""count" => "0""text" => "0.00&euro; - 19.99&euro;""min" => "0.00""max" => "19.99"),
array(
"number" => "2""count" => "0""text" => "20.00&euro; - 39.99&euro;""min" => "20.00""max" => "39.99"),
array(
"number" => "3""count" => "0""text" => "40.00&euro; - 59.99&euro;""min" => "40.00""max" => "59.99"),
array(
"number" => "4""count" => "0""text" => "60.00&euro; - 79.99&euro;""min" => "60.00""max" => "79.99"),
array(
"number" => "5""count" => "0""text" => "80.00&euro; - 99.99&euro;""min" => "80.00""max" => "99.99"),
array(
"number" => "6""count" => "0""text" => "100.00&euro; - 199.99&euro;""min" => "100.00""max" => "199.99"),
array(
"number" => "7""count" => "0""text" => "200.00&euro; - 299.99&euro;""min" => "200.00""max" => "299.99"),
array(
"number" => "8""count" => "0""text" => "300.00&euro; - 399.99&euro;""min" => "300.00""max" => "399.99"),
array(
"number" => "9""count" => "0""text" => "400.00&euro; - 599.99&euro;""min" => "400.00""max" => "599.99"),
array(
"number" => "10""count" => "0""text" => "600.00&euro; - 799.99&euro;""min" => "600.00""max" => "799.99"),
array(
"number" => "11""count" => "0""text" => "800.00&euro; - 999.99&euro;""min" => "800.00""max" => "999.99"),
array(
"number" => "12""count" => "0""text" => "1000.00&euro; - 1199.99&euro;""min" => "1000.00""max" => "1199.99"),
array(
"number" => "13""count" => "0""text" => "1200.00&euro; - 1399.99&euro;""min" => "1200.00""max" => "1399.99"),
array(
"number" => "14""count" => "0""text" => "1400.00&euro; - 1599.99&euro;""min" => "1400.00""max" => "1599.99"),
array(
"number" => "15""count" => "0""text" => "1600.00&euro; - 1799.99&euro;""min" => "1600.00""max" => "1799.99"),
array(
"number" => "16""count" => "0""text" => "1800.00&euro; - 1999.99&euro;""min" => "1800.00""max" => "1999.99"),
array(
"number" => "17""count" => "0""text" => "2000+")
);
foreach (
$searchresults["products"] as $product){
if (
$product["price"] > and $product["price"] < 19.99) {$bracket['0']['count'] = $bracket['1']['count'] + 1;}
if (
$product["price"] > 20 and $product["price"] < 39.99) {$bracket['1']['count'] = $bracket['2']['count'] + 1;}
if (
$product["price"] > 40 and $product["price"] < 59.99) {$bracket['2']['count'] = $bracket['3']['count'] + 1;}
if (
$product["price"] > 60 and $product["price"] < 79.99) {$bracket['3']['count'] = $bracket['4']['count'] + 1;}
if (
$product["price"] > 80 and $product["price"] < 99.99) {$bracket['4']['count'] = $bracket['5']['count'] + 1;}
if (
$product["price"] > 100 and $product["price"] < 199.99) {$bracket['5']['count'] = $bracket['6']['count'] + 1;}
if (
$product["price"] > 200 and $product["price"] < 299.99) {$bracket['6']['count'] = $bracket['7']['count'] + 1;}
if (
$product["price"] > 300 and $product["price"] < 399.99) {$bracket['7']['count'] = $bracket['8']['count'] + 1;}
if (
$product["price"] > 400 and $product["price"] < 599.99) {$bracket['8']['count'] = $bracket['9']['count'] + 1;}
if (
$product["price"] > 600 and $product["price"] < 799.99) {$bracket['9']['count'] = $bracket['10']['count'] + 1;}
if (
$product["price"] > 800 and $product["price"] < 999.99) {$bracket['10']['count'] = $bracket['11']['count'] + 1;}
if (
$product["price"] > 1000 and $product["price"] < 1199.99) {$bracket['11']['count'] = $bracket['12']['count'] + 1;}
if (
$product["price"] > 1200 and $product["price"] < 1399.99) {$bracket['12']['count'] = $bracket['13']['count'] + 1;}
if (
$product["price"] > 1400 and $product["price"] < 1599.99) {$bracket['13']['count'] = $bracket['14']['count'] + 1;}
if (
$product["price"] > 1600 and $product["price"] < 1799.99) {$bracket['14']['count'] = $bracket['15']['count'] + 1;}
if (
$product["price"] > 1800 and $product["price"] < 1999.99) {$bracket['15']['count'] = $bracket['16']['count'] + 1;}
if (
$product["price"] > 2000) {$bracket['17']['count'] = $bracket['16']['count'] + 1;}
}
foreach (
$bracket as $key => $value){
    if (
$value['count'] > 0) {
        print 
"<form method='GET' action='".$config_baseHREF."search.php'>";
  
widget_selectArray("value",$value['text'],"&minPrice=".$value['min']."&maxPrice=".$value['max'],"");
  print 
"<input type='hidden' name='q' value='".($q)."' />";
  print 
"<input type='submit' value='Go' />";
  print 
"</form>";
    }
}
?>

Submitted by support on Sun, 2008-08-24 11:17

Thanks, Guillaume.

I've picked up the files you sent me by email - i'll get back to you by email about this...

Cheers,
David.

Submitted by paddyman on Fri, 2008-08-29 00:09

Hi David,

Have seen several mentions about using price brackets over the last few weeks in several threads. A little bit confused as to where to put the above code and how I could have price ranges listed in a menu. Has anyone successfully implemented this?

Thanks

Adrian

Submitted by support on Fri, 2008-08-29 07:35

Hi Adrian,

The first thing that is required is the min/max price mods that enable search.php to receive minPrice and maxPrice parameters. I'll email you this mod if you have not yet implmented it, then i'll help through this thread with a generic version of the price bracket drop down...

Cheers,
David.

Submitted by paddyman on Fri, 2008-08-29 07:53

Thanks for the Mods. Will give it a go.

Cheers

Adrian

Submitted by paddyman on Sun, 2008-08-31 16:13

Hi David,

I've modified my navigation.php and search.php files and included the minprice/maxprice mods. Looking at having something the price ranges listed on a left menu I have, similar to the left menu which Dealclick have

http://ggl.dealclick.co.uk/subcat/camcorders.php

Where would I add the price arrays above?

Thanks

Adrian

Submitted by support on Sun, 2008-08-31 16:52

Hi Adrian,

bear with me and i'll work out the price bracket code for you - I just need to setup a test site with the price mods...

Cheers,
David.