View Single Post
  #5  
Old May 10th, 2012, 10:36 AM
fsuggest fsuggest is offline
 
Join Date: Apr 2012
Posts: 45
Default

Hey Eric,

Was hoping for your clarification.

I currently have this code generating a drop down of my merchants in my theme's function.php file:

Code:
function dfr_get_merchants_dropdown() {
    global $wpdb;
    $merchants = $wpdb->get_results("SELECT merchant, merchant_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
    $html = '<option value="">All stores</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;
}
The code in my widget is:

Code:
  <p class="merchant">
    <label for="merchant">Store</label>
    <select name="merchant_id" style="width: 195px;" value=''>
      <?php echo dfr_get_merchants_dropdown(); ?>
    </select>
  </p>
And the code in my search results page is:

Code:
<?php if (@$_GET['merchant_id']){ ?><li><b>Merchant: </b>[store.get param="merchant_id"]</li><?php } ?>
If I was to switch the following line in the functions.php file:

Code:
$html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';
to

Code:
$html .= '<option value="'.$v->merchant.'"'.$selected.'>'.$v->merchant.'</option>';
Then change the widget code to:

Code:
  <p class="merchant">
    <label for="merchant">Store</label>
    <select name="merchant" style="width: 195px;" value=''>
      <?php echo dfr_get_merchants_dropdown(); ?>
    </select>
  </p>
And search results page code to:

Code:
<?php if (@$_GET['merchant']){ ?><li><b>Merchant: </b>[store.get param="merchant"]</li><?php } ?>
Would that cause any problems? As you mentioned before, I wouldn't want punctuations in the merchants name to mess with my search results.

Thank you.