Datafeedr Support Forums

Datafeedr Support Forums (http://www.datafeedr.com/forums/index.php)
-   Questions (http://www.datafeedr.com/forums/forumdisplay.php?f=67)
-   -   Drop Down for price categories working together with category drop down (http://www.datafeedr.com/forums/showthread.php?t=6111)

meinehandtasche January 18th, 2012 09:55 AM

Drop Down for price categories working together with category drop down
 
Store ID: 32722
Website URL: http://www.meinehandtasche.de/
URL to page in question: http://www.meinehandtasche.de/store/

Hi Eric,

I am working on a price filter as drop down that works together with the drop down brand filter.
Currently I just use the following which works perfectly but it would be much nicer to have a drop down:

I pasted within / Factory > Widgets > new brand filter widget the following code in a / text / widget view module:

Quote:

Prices:
<ul>
<?php if (@$_GET['price']) { ?>

<li><a href="[server.url type='fullpage' query='-price']">[X] delete price filter</a></li>

<?php } else { ?>

<li><a href="[server.url type='fullpage' query='price=-50']">< 50</a></li>
<li><a href="[server.url type='fullpage' query='price=50-100']"> 50 - 100</a></li>
<li><a href="[server.url type='fullpage' query='price=100-150']"> 100 - 150</a></li>
<li><a href="[server.url type='fullpage' query='price=150-250']"> 150 - 250</a></li>
<li><a href="[server.url type='fullpage' query='price=250-500']"> 250 - 500</a></li>
<li><a href="[server.url type='fullpage' query='price=500-1000']"> 500 - 1.000</a></li>
<li><a href="[server.url type='fullpage' query='price=1000-']">> 1.000</a></li>

<?php } ?>
</ul>

How can I get this done as a drop down as mentioned above?

Thanks,
Oliver

Eric January 18th, 2012 11:17 AM

Hi

So if you are using the drop down brand code from here, here's how a price drop down could be integrated into the form:

In your View:
HTML Code:

<form method="get" action="[server.url type='fullpage']">
 
  <select name="brand">
    <?php echo dfr_get_brands(); ?>
  </select>
 
  <select name="price">
    <?php echo dfr_get_prices(); ?>
  </select>
 
  <input type="submit" value="Go" />
 
</form>

In your functions.php file:
PHP Code:

function dfr_get_prices() {
    $price = strip_tags(@$_GET['price']);
    ?>
    <option value="-50" <?php if ($price=="-50"){echo ' selected="selected"';} ?>>Less than $50</option>
    <option value="50-200" <?php if ($price=="50-200"){echo ' selected="selected"';} ?>>$50 - $200</option>
    <option value="200-" <?php if ($price=="200-"){echo ' selected="selected"';} ?>>More than $200</option>
    <?php
}

function 
dfr_get_brands() {
    global 
$wpdb;
    
$brands $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products GROUP BY brand");
    
$html '';
    foreach (
$brands as $brands) {
        
$selected = (@$_GET['brand'] == $brands->brand) ? ' selected="selected"' '';
        
$html .= '<option value="'.$brands->brand.'"'.$selected.'>'.($brands->brand).'</option>';
    }
    return 
$html;
}

Those work with each other.

Eric

meinehandtasche January 18th, 2012 12:13 PM

Store ID: 32722
Website URL: http://www.meinehandtasche.de/
URL to page in question: http://www.meinehandtasche.de/store/

Hi Eric,

It works like a charme :-)
Thank you so much! You made my day! :-)

Oliver


All times are GMT -5. The time now is 12:21 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.