Datafeedr Support Forums

Datafeedr Support Forums (http://www.datafeedr.com/forums/index.php)
-   Tips, Tricks & Tutorials (http://www.datafeedr.com/forums/forumdisplay.php?f=66)
-   -   Filter onsale items (http://www.datafeedr.com/forums/showthread.php?t=6211)

sdc247 February 3rd, 2012 03:20 PM

Filter onsale items
 
Is there a way to filter my onsale items? I would like to have a search area that will only search my onsale page. This search field will only be displayed on my onsale page only. So if a person is searching for HDMI cable it will only bring back those items that are on sale.

James
sdc24-7.com

Eric February 3rd, 2012 05:32 PM

Hi

I guess you could add the following code to your Search Widget. This will add a saleprice parameter to the search results.

HTML Code:

<input type="hidden" name="saleprice" value="1-" />
Therefore your Simple Search widget would look like this:

HTML Code:

<script type="text/javascript">
<!--
/*
 * NOTE: This JS code would be much better off
 * existing in your theme's header.php file.
*/
function wash( anInput ) { if(anInput.value == anInput.defaultValue) anInput.value = ''; }
function checkWash( anInput ) { if(anInput.value == '') anInput.value = anInput.defaultValue; }
//-->

</script>

<div class="store_search_form">
  [search.form]
  [search.word onfocus='wash(this);' onblur='checkWash(this);' value='Search store...']
  <input type="hidden" name="saleprice" value="1-" />
  [search.submit title='Go']
  [/search.form]
</div>

Eric

sdc247 February 7th, 2012 05:56 PM

Okay thank you, That fixed a different problem. However that still does not do what I need. What I want is when a viewer is on my "Onsale" page and they use the search field, I only want items to show that are on sale only. However if they are on any other page I want the search to bring back normal searches. I hope I am making sense.

James

Eric February 7th, 2012 07:14 PM

Hi

Then you'd need something like this (if your search page is here: /store/search):

HTML Code:

<div class="store_search_form">
  [search.form]
  [search.word onfocus='wash(this);' onblur='checkWash(this);' value='Search store...']
  <?php if (preg_match("/store\/search/i", $_SERVER['REQUEST_URI'])) { ?>
          <input type="hidden" name="saleprice" value="1-" />
  <?php } ?>
  [search.submit title='Go']
  [/search.form]
</div>

Eric

tcsar757 November 6th, 2012 07:52 PM

Could i make a new widget and show it only on the sale items page with this code or is there another code i should use or another way to set it up so i can make a widget for only sale page for searching only sale items.
Thanks

Eric November 7th, 2012 01:03 AM

Quote:

Originally Posted by tcsar757 (Post 37227)
Could i make a new widget and show it only on the sale items page with this code or is there another code i should use or another way to set it up so i can make a widget for only sale page for searching only sale items.
Thanks

Sure, you could add a text widget to your sidebar with the following info:
HTML Code:

<form method="get">
        <input type="hidden" name="saleprice" value="1-" />
        <input type="submit" value="Show On Sale Items" />
</form>


tcsar757 November 7th, 2012 08:25 PM

Sorry maybe i was not clear enough, I want to have a seperate search widget that will only search sale items on my sale items page while simple search widget searches rest of store.Thats what i thought this code was supposed to do.

Eric November 7th, 2012 10:32 PM

Hi,

You can create a new widget, add a text module to that widget with the following code:
HTML Code:

<script type="text/javascript">
<!--
/*
 * NOTE: This JS code would be much better off
 * existing in your theme's header.php file.
*/
function wash( anInput ) { if(anInput.value == anInput.defaultValue) anInput.value = ''; }
function checkWash( anInput ) { if(anInput.value == '') anInput.value = anInput.defaultValue; }
//-->

</script>

<div class="store_search_form">
  <form method="get" action="http://www.YOURSITE.com/store/search">
          [search.word onfocus='wash(this);' onblur='checkWash(this);' value='Search store...']
          <input type="hidden" name="saleprice" value="1-" />
          [search.submit title='Go']
  </form>
</div>

Make sure you change http://www.YOURSITE.com/store/search to your site's search page.

Then add that new widget to only your search page using the Widget Context plugin.

Eric


All times are GMT -5. The time now is 10:39 AM.

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