![]() |
|
Home | Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]() Hey,
I was following the post at http://www.datafeedr.com/forums/showthread.php?t=6778 to display brands and merchants in a drop down. I realize that the merchant ID is being used to gather the information but was wondering what would be the code to insert in my search page to display the merchant's name instead of the id number. Right now I have: Code:
<?php if (@$_GET['merchant_id']){ ?><li><b>Merchant: </b>[store.get param="merchant_id"]</li><?php } ?> Code:
<?php if (@$_GET['merchant_id']){ ?><li><b>Merchant: </b>[store.get param="merchant"]</li><?php } ?> Any suggestions? Store ID: 37285 Website URL: www.FriendsSuggest.com Thank you. |
#2
|
||||
|
||||
![]() Hi
We don't recommend the merchant name because with merchant names you have to take into consideration punctuation like apostrophes and quotes and all of that needs to be escaped. Merchant IDs are much less prone to errors. Eric
__________________
![]() ![]() ![]() ![]() |
#3
|
|||
|
|||
![]() Hey Eric,
I agree the id is less prone to error. What I was hoping for is to give the merchants name when someone does a search on my site. For example, where it displays what was searched for: Description: jeans Brand: Guess Merchant: Amazon (instead of a id number as the name is more descriptive for the user) Thank you. |
#4
|
||||
|
||||
![]() Hi
Then you'll want to change your code to this: <?php if (@$_GET['merchant']){ ?><li><b>Merchant: </b>[store.get param="merchant"]</li><?php } ?> Eric
__________________
![]() ![]() ![]() ![]() |
#5
|
|||
|
|||
![]() 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; } 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> Code:
<?php if (@$_GET['merchant_id']){ ?><li><b>Merchant: </b>[store.get param="merchant_id"]</li><?php } ?> Code:
$html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>'; Code:
$html .= '<option value="'.$v->merchant.'"'.$selected.'>'.$v->merchant.'</option>'; Code:
<p class="merchant"> <label for="merchant">Store</label> <select name="merchant" style="width: 195px;" value=''> <?php echo dfr_get_merchants_dropdown(); ?> </select> </p> Code:
<?php if (@$_GET['merchant']){ ?><li><b>Merchant: </b>[store.get param="merchant"]</li><?php } ?> Thank you. |
#6
|
||||
|
||||
![]() HiNo, but...
Quote:
You are going to have to query the database to get the merchant's name from the merchant's ID here: The Factory > Your Store > VIEWS > SEARCH PAGE > Default > Product list module: HTML Code:
<?php if (@$_GET['merchant']) { ?> <li> <b>Merchant: </b> <?php PHP CODE TO QUERY DB ?> </li> <?php } ?>
__________________
![]() ![]() ![]() ![]() |
#7
|
|||
|
|||
![]() Hey Eric,
Appreciate the quick reply. Tried your suggestion but I'm not sure where my code is wrong. Here's what I've done: In function.php, I use: 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; } 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> Code:
<!-- Search Fields --> <ul> <?php if (@$_GET['word']){ ?><li><b>Description: </b>[store.get param="word"]</li><?php } ?> <?php if (@$_GET['brand']){ ?><li><b>Brand: </b>[store.get param="brand"]</li><?php } ?> <?php if (@$_GET['category']){ ?><li><b>Category: </b>[store.get param="category"]</li><?php } ?> <?php if (@$_GET['merchant_id']) { ?> <li> <b>Store: </b> <?php $merchant = $wpdb->get_row("SELECT merchant FROM ".$wpdb->prefix."dfr_shop_products WHERE merchant_id = $_GET['merchant_id']"); echo $merchant; ?> </li> <?php } ?> <?php if (@$_GET['tags']){ ?><li><b>Tags: </b>[store.get param="tags"]</li><?php } ?> <?php if (@$_GET['saleprice']){ ?><li><b>Price: </b>$[store.get param="saleprice"]</li><?php } ?> </ul> <!-- /Search Fields --> Can you see where I'm going wrong in my code? Thank you. Last edited by fsuggest : May 10th, 2012 at 09:20 PM. |
#8
|
||||
|
||||
![]() Hi
Adding something like this to your View: HTML Code:
<?php if (@$_GET['merchant_id']) : ?> <li> <b>Merchant: </b> <?php echo dfr_get_merchant($_GET['merchant_id']); ?> </li> <?php endif; ?> PHP Code:
Eric
__________________
![]() ![]() ![]() ![]() |
#9
|
|||
|
|||
![]() Awesome! Thanks Eric.
One thing I've noticed is that the search results is returning paginated pages with the last several pages showing blank results. For example, if you just hit the submit button on the top left hand sidebar search it returns 60 pages but pages 57-60 are blank. Thank you. |
#10
|
||||
|
||||
![]() Hi
Quote:
PHP Code:
__________________
![]() ![]() ![]() ![]() |
#11
|
|||
|
|||
![]() Hey Eric,
But doesn't that if statement act as a filter to only display the items based on the conditions I've set? Thank you. |
#12
|
||||
|
||||
![]() Hi
Yes, but it doesn't modify the query on the database which returns more products (and creates the pagination links to pages that don't have products because of the if filter). Eric
__________________
![]() ![]() ![]() ![]() |
#13
|
|||
|
|||
![]() Thanks Eric. I will have to take a look into the products in inventory.
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Merchant Not Showing in Merchant Filter | dk3 | Problems | 2 | March 9th, 2012 01:42 PM |