![]() |
|
Home | Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]() Hi
Is it possible to set a filter by a user generated min and max price? I know you can set up a filter along the the lines of 10-20, 20-30, 30-40 and so on, but what I'm looking for is a way for the user to set a minimum and maximum price, in the same way as it's done in the factory product search. I'm currently rebuilding a site that I haven't touched for a couple of years and want to add a price filter to the sort order form on the category page. Thanks Paul |
#2
|
||||
|
||||
![]() Hi,
Yes, it's a little tricky because you have 2 input fields which need to make up 1 $_GET value. For example, you need to have a Min and Max input field but pass the "price" field to the browser with the min and max as part of the "price" field. Here's how you might be able to do it using jQuery: http://jsfiddle.net/oreamnos/utTYM/1/ Eric
__________________
![]() ![]() ![]() ![]() |
#3
|
|||
|
|||
![]() That was quick. I wasn't expecting a reply until tomorrow.
I did think about javascript, but was hoping to get away with not using it, as the form will add the 3 values to the url. but that's not really a big issue. what I was wondering though was whether I could use php to add the two values together by adding a bit of code somewhere in the plugin code. |
#4
|
||||
|
||||
![]() Hi,
I'm not 100% sure but I don't think that it's possible to add more $_GET variables to the URL without intercepting the request and redirecting it. Eric
__________________
![]() ![]() ![]() ![]() |
#5
|
|||
|
|||
![]() Thanks Eric
I'm having a play with the Javascript option. I'll post a link if I get it working. Many Thanks. Paul |
#6
|
||||
|
||||
![]() Hi Paul,
OK, thanks! Eric
__________________
![]() ![]() ![]() ![]() |
#7
|
|||
|
|||
![]() I've got it working with the javascript.
http://www.happydogproducts.co.uk/st...roof-dog-beds/ This is the Min Max Price html that I added to the form Code:
Price:<br /> Min <input type="text" size="4" value="<?php echo $_GET['minp']; ?>" name="minp" onChange="updateprice()" /> Max <input type="text" size="4" value="<?php echo $_GET['maxp']; ?>" id="maxp" name="maxp" onChange="updateprice()" /> <input type="hidden" name="price" value="<?php echo $_GET['price']; ?>" /> Code:
<script type="text/javascript"> function updateprice() { document.sorder.price.value = document.sorder.minp.value + '-' + document.sorder.maxp.value; } </script> |
#8
|
||||
|
||||
![]() Hi Paul,
Thanks for sharing! Glad you got it working! Eric
__________________
![]() ![]() ![]() ![]() |
#9
|
|||
|
|||
![]() Store ID: 349234
Website URL: www.petiteoutdoor.com/store Morning! I just have a question about the integration of this filter into a widget. I'm new to javascript and it's integration into wordpress, I've only worked with php and css thus far. Can you detail where to put the javascript function (i'm assuming it goes in the functions.php file), any additional calls I may need or definitions to put it there and an example of the html to put in the widget? Thanks so much! ![]() PS. The only help I've found is at the following link but being a newbie it's still kind of confusing for me: http://codex.wordpress.org/Using_Javascript Last edited by mlt01005 : January 23rd, 2014 at 01:18 PM. |
#10
|
||||
|
||||
![]() Hi,
I believe the other user simply placed it in their views with the HTML code. Eric
__________________
![]() ![]() ![]() ![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Price filter | thk1976 | Problems | 4 | March 23rd, 2013 05:29 PM |
Price filter has a bug | officialwatch | Problems | 1 | November 6th, 2012 08:26 AM |
Price filter | quitjob | Questions | 1 | March 18th, 2012 09:59 AM |
'Remove Price filter' like brand filter | Giftoly | Questions | 1 | January 20th, 2012 10:48 AM |
Price Filter Not Working | bredies | Problems | 1 | May 29th, 2011 12:18 AM |