Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Tips, Tricks & Tutorials
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 29th, 2011, 01:59 PM
Nugerama Nugerama is offline
 
Join Date: Mar 2011
Posts: 14
Default Merchant and Brand filter Widgets

Hi, I just installed and began using Datafeedr today an flippin' love it, I wonder though if you can help me with this little issue.

I've playing about with the widgets and it's all been made very easy to set up but I wonder if there's a way of having the Merchant and Brand filters automatically populated according to the products that are in my store in the same was as the Category one is?

I see how the widget is edited manually but I'd like to be able to hand this over to my client when it's all done knowing that those widgets will stay up to date, let's say if she adds a merchant to the store, without me having to log in and edit the widget.

Thanks very much for you time
Kev
  #2  
Old March 29th, 2011, 02:21 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi Kev,

You could always add a couple of queries and add those to theme's functions.php file. But, there might be way more merchants and or brands than you might anticipate:

Here's one that could work for your merchants. You can do the same thing for brands.

PHP Code:
function dfr_get_merchants() {
    global 
$wpdb;
    
$merchants $wpdb->get_results("SELECT merchant FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
    
$list = array();
    foreach (
$merchants as $merchants)
        
$list[] = $merchants->merchant;
    return 
$list;

Then you could add something like this in your views:

PHP Code:
<?php
$merchants 
dfr_get_merchants();
foreach (
$merchants as $merchant) {
    echo 
'<li><a href="[server.url type=\'fullpage\' query=\''.$merchant).'\']">'.$merchant).'</a></li>';
}
?>
You might need to tweak that to meet your needs but it should get you in the ballpark.

Eric
  #3  
Old March 31st, 2011, 01:27 PM
Nugerama Nugerama is offline
 
Join Date: Mar 2011
Posts: 14
Default

Hi Eric, this has almost got it, the function works great and the I'm getting an automatically generate list of merchants. The links however don't work and I can't figure out why. Could you take a look please at the 'Stores' widget on my home page and give advise me on fixing it so that these links are interpreted correctly.

My dev site can be found at www.hersuits.co.uk/dev

Many thanks
Kev
  #4  
Old March 31st, 2011, 01:38 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Try this:
PHP Code:
<?php
$merchants 
dfr_get_merchants();
foreach (
$merchants as $merchant) {
    echo 
"<li><a href=\"[server.url type='fullpage' query='$merchant']\">$merchant</a></li>";
}
?>
  #5  
Old March 31st, 2011, 01:57 PM
Nugerama Nugerama is offline
 
Join Date: Mar 2011
Posts: 14
Default

Hi Eric. Sadly, that's not done it. In fact it stops outputting the buttons at all.

If I add some dots either side of the variables I get the buttons back but still not tracing out the link correctly. I've left it as echo "<li><a href=\"[server.url type='fullpage' query='.$merchant.']\">.$merchant.</a></li>"; for you to have a look at. www.hersuits.co.uk/dev

Thanks
Kev
  #6  
Old March 31st, 2011, 02:17 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

OK, I figured out the issue. Try this:
PHP Code:
<ul>
<?php
$merchants 
dfr_get_merchants();
foreach (
$merchants as $merchant) { 
    
$merchant urlencode($merchant);
    
?>
    <li><a href="[server.url type='fullpage' query='merchant=$merchant']"><?php echo urldecode($merchant); ?></a></li>
<?php ?>
</ul>
  #7  
Old March 31st, 2011, 02:52 PM
Nugerama Nugerama is offline
 
Join Date: Mar 2011
Posts: 14
Default

Aces!!! That's done it, thanks again Eric.
  #8  
Old February 20th, 2012, 07:50 AM
wildstyles wildstyles is offline
 
Join Date: Feb 2012
Posts: 21
Default

Store ID: 36187
Website URL: http://www.thewildstyles.com
URL to page in question: http://www.thewildstyles.com/store/category/clothing/

Hi there,
This piece of code works really good. I've managed to pull all my brands from the database with this code.
I've used the code from ""Creating Filters" post to put the list in a dropdown..
See the code:

<?php if (@$_GET['brand']) { ?>

<h6><a href="[server.url type='fullpage' query='-brand']">[X] Remove your choice "[store.get param="brand"]"</a></h6>

<?php } else { ?>

<form method="get">
<select name="brand" onchange='this.form.submit()'>
<?php
$brands = dfr_get_brands();
foreach ($brands as $brand) {
$brand = urlencode($brand);
?>

<option value="<?php echo urldecode($brand); ?>"<?php if (@$_GET['brand']) {echo ' selected="selected"';}?>><?php echo urldecode($brand); ?></option>

<?php } ?>
</select>
</form>

<?php } ?>


Now my issue is that when I have other filters on (merchant, etc) and I choose a different brand, it erases all the other filters and goes to the brand page.. While all other filters don't have that issue, you can add and remove as many as you want without overriding anything.
So Im sure I've made some errors in the code, I'm not an expert unfortunately. Could either of you help me out with this?

Thanks in advance.
Ivar Zuidhoek.
  #9  
Old February 20th, 2012, 10:30 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You'll need to pass those parameters along in your <form>. So, between <form> and </form> you can add something like this:

HTML Code:
 <?php if (@$_GET['merchant']){ echo "<input type='hidden' name='merchant' value='".strip_tags($_GET['merchant'])."' />"; } ?>
Eric
  #10  
Old February 20th, 2012, 11:02 AM
wildstyles wildstyles is offline
 
Join Date: Feb 2012
Posts: 21
Default

hey Eric,

thanks for your fast response. really appreciate it.

however when I included that line inbetween <form> and </form> what happened is that when I selected a brand, then an merchant, then remove the brand, I couldn't pick another brand..

maybe it easier to see for yourself, you can see the filters @ work here:

http://www.thewildstyles.com/store/category/clothing/
  #11  
Old February 20th, 2012, 11:31 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You need to put the above code within the <form> tags but not between the <select> tags. It should appear immediately after the <form> tag and just before the <select> tag.

Eric
  #12  
Old February 20th, 2012, 12:18 PM
wildstyles wildstyles is offline
 
Join Date: Feb 2012
Posts: 21
Default

works like a charm. brilliant. thank you so much.
  #13  
Old March 7th, 2012, 03:54 PM
wildstyles wildstyles is offline
 
Join Date: Feb 2012
Posts: 21
Default

Store ID: 36187
Website URL: http://www.thewildstyles.com
URL to page in question: http://www.thewildstyles.com/store/category/clothing/

I have another question about this piece of code.
It works great.

However I'm gonna have a few main categories later on, like Clothing, Music, Accesoires..
I only wanna draw the brands from articles I add to the clothing category..
Is that possible?
  #14  
Old March 7th, 2012, 05:01 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You could modify the query like this:

PHP Code:
function dfr_get_merchants() { 
    global 
$wpdb
    
$merchants $wpdb->get_results("SELECT merchant FROM ".$wpdb->prefix."dfr_shop_products WHERE cat_id = 670426 GROUP BY merchant"); 
    
$list = array(); 
    foreach (
$merchants as $merchants
        
$list[] = $merchants->merchant
    return 
$list

Replace 670426 with the Category ID you want to pull products from.

Eric
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Brand Filter Drop-Down with All Brands option meperez Questions 8 March 26th, 2011 12:04 AM
Brand Filter = Brands Only show when in Category macfink Questions 3 March 25th, 2011 12:55 PM
Drop down Menu from filter by Brand macfink Questions 4 March 25th, 2011 09:32 AM
Brand filter? sylviathewitch Problems 3 March 8th, 2011 08:43 AM
Merchant Filter Will Not Show Merchant Correctly laura90059 Questions 6 March 7th, 2011 10:46 PM


All times are GMT -5. The time now is 06:58 PM.


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