WP E-Commerce Adjust Price Range Widget
Here I am again, talking about another issue with WP-Ecommerce… the Price Range Widget. More specifically, the inability to make any adjustments to the ranges specified from the WordPress dashboard. I know WP E-Commerce is free, but do they even offer this ability in their upgraded packages (ability to change price ranges in widget)? Probably not. Which is another story in and of itself, but I’m going to keep this short.
I have seen many people post about this issue across the internet, even on getshopped.org, WP Ecommerce’s official home– but none of the threads have any solid answers. How can I change my price ranges in the Price Range Widget?
My official answer: You still can not adjust them to be exactly a certain range, but you can adjust some of the arguments in the php and get it to be much more accurate, especially for sites selling things UNDER 10 DOLLARS!!! Please, keep reading… I think you’ll like my workaround.
Quickly…
Open
/wp-content/plugins/wp-e-commerce/wpsc-widgets/price_range_widget.php
in your favorite text editor.
Go to line 115 and you will see the following code:
So, aside from the bad grammar (seperater?) this function performs the math to gather and generate the price ranges and I read in another forum that you can play with this number and get different price ranges. This is true. I started changing the “6” to “5” or “15” or even “-1” just to see what was going on. Basically, this number separates the price ranges by price and the higher number, the more price ranges you get, the lower the number, the less you get. For those that care, “-1” threw an error. Anyhow, this led me to do some more sleuthing…
By just changing this number we can alter the price ranges, not to an exact number but it’s a start. Although, even in doing this, the lowest price in the range was $10.00. The store that it was applied to had multiple items under $10 that were getting passed over by the price ranges widget. Why was this happening? It just didn’t seem right.
So on a whim, I went a few lines down on the page to line 117 and saw the following code:
Also, on a whim I decided to change the “-1” value to “-0”. Saved the page and refreshed in the browser. Guess what… my products under $10 dollars were now appearing in the price range widget and it made the price ranges much more relative to the products being sold. From there, I revisited the first line of code we discussed. Changed that value to “5” and and was able to find a viable solution for my clients price range needs.
Of course, there are many other factors that will decide whether or not this will work for you. You may have to play with that “$count / 6” divider to get the exact results you’re looking for but after changing the “-1” to “-0”, it’s like the entire widget started making better decisions in its price range calculations. How strange.
Once again, after you modify any core file, you have to save a copy locally until the next plugin update comes out. Then once you update the plugin, re-upload the core file and overwrite the existing one.
If someone want’s to help me come up with a “functions.php” filter for this… I’m all ears. Until then, hope this worked for you and I look forward to your comments.
Hi,
Very good information , I would like change my prices Range as well.But I can’t find /wp-content/plugins/wp-e-commerce/wpsc-widgets/price_range_widget.php. In my website
And tried to find price range in my WPSC default CSS. I have this code but no prices.
Do you know, How I can change it ? or where I can find this information
Ben Kaminski
Post author
@AnnSo
I’m sorry to disappoint but even on the latest version of WP E-Commerce, the file is still in that location. If you’re not seeing it, perhaps it’s a permissions issue on your server. Either way, I can assure you that the file is located in that folder. Maybe you should re-download the plugin and check the core files from the .zip file?
Ben Kaminski
Post author
Thanks for the update alextmb!
Leave a Comment Below...