View Single Post
  #2  
Old October 28th, 2012, 04:10 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Store ID: 16iizsa3ku6mhoje
Website URL: http://www.paardenlifestyle.com/store

Hi Eric,

thanks for posting that. It has been a bit quiet in my shop the last two weeks; I'd figured I had to contact the merchants and try to make sure they fill out brand and the appropriate tag, because it has been a lot of work for me. So I'm in the middle of doing that. I did make a bit of money in last month (almost €200!). I think that's quite good since I only started in september. I'm doing very well in Google, but that's probably because I have a blog attached to it.

Anyway, my question. I have a drop down for merchant and brand which works great. Now I was wondering how to include the dropdown menu for categories since my drop down code is a bit different and I'm not using the widget (since I attach specific ID's to the filters).

The code I have it as follows (for the page http://www.paardenlifestyle.com/stor.../bovenkleding/ )



HTML:

<form method="get">
<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Selecteer merk</p><select name="brand">
<?php echo dfr_get_brands('991838,991938,992029,992447'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px; margin-top: 10px;">Selecteer webshop</p><select name="merchant_id">
<?php echo dfr_get_merchants('991838,991938,992029,992447'); ?>
</select>
<p style="margin-bottom: 20px;"></p>
<input type="submit" value="Zoeken" />

</form>



functions.php :

function dfr_get_brands($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE p2c.cat_id IN (".$cat.") "; }
$brands = $wpdb->get_results("
SELECT brand, p2c.cat_id
FROM ".$wpdb->prefix."dfr_shop_products AS p
INNER JOIN ".$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id
$cat_query
GROUP BY brand
");
$html = '<option value="">Alle merken</option>';
foreach ($brands as $brands) {
if (trim($brands->brand) != "") {
$selected = (strip_tags(stripslashes($_GET['brand']))==$brands->brand) ? ' selected="selected"' : '';
$html .= '<option value="'.$brands->brand.'"'.$selected.'>'.$brands->brand.'</option>';
}
}
return $html;
}

function dfr_get_merchants($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE p2c.cat_id IN (".$cat.") "; }
$merchants = $wpdb->get_results("
SELECT merchant, merchant_id, p2c.cat_id
FROM ".$wpdb->prefix."dfr_shop_products AS p
INNER JOIN ".$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id
$cat_query
GROUP BY merchant
");
$html = '<option value="">Alle webshops</option>';
foreach ($merchants as $k => $v) {
if (trim($v->merchant) != "") {
$selected = (strip_tags($_GET['merchant_id'])==$v->merchant_id) ? ' selected="selected"' : '';
$html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';
}
}
return $html;
}

How do I add the dropdown for categories? I'm assuming I have to fill out the ID's for the categories I want to show up in the filter for certain pages? In this example I would only want to show the categories from the IDs 991838, 991938, 992029 and 992447.

When I simply add the code you've shown to the HTML (the category filter), it doesn't show the categories, just an empty dropdown.

I hope you can help me out Thanks in advance!

Best regards,

Conny