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…
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.
If you found this article helpful, please share on social media.
Leave a Comment Below...