Fixing Grid and List Views in WP e-Commerce Gold
Recently, one of my clients asked me to setup and configure an online store using WordPress and the plugin WP e-Commerce Gold by Instinct Entertainment. As a part of the design, I needed to implement the Grid View module to display the products in a nice layout. Unfortunately, whenever I tried to use the Grid View, I was confronted with this error:
Fatal error: Call to undefined function wpsc_product_url() in grid_display_functions.php on line 47
A quick search of all the files for this plugin revealed that function wpsc_product_url(){…} was nowhere to be found. Furthermore, searching on “undefined function wpsc_product_url()” revealed that others are having this problem too, and the admins on the forums at Instinct Entertainment don’t seem to be too helpful either. So, I had to come up with my own patch which I am happy to share with everyone else who has run into the same problem.
The Problem
The Grid View module currently available for purchase on the Instinct website requires the function wpsc_product_url() to generate links to each of the products featured in the grid view. The problem is that this function does not exist in the latest stable version of the plugin (3.5.1); however, it is found in the beta version (3.6 Beta 8).
The Solution
To get rid of the fatal error and get the grid view working, I took the wpsc_product_url() function from the file product_display_functions.php in WP e-Commerce 3.6 Beta 8, removed some 3.6 Beta 8 specific code and added the trimmed down function to the same file in WP e-Commerce 3.5.1.
And now, here’s the function we’ve all been waiting for
:
function wpsc_product_url($product_id, $category_id = null){
global $wpdb;
if(!stristr(get_option('product_list_url'), "?")) {
$initial_seperator = "?";
} else {
$initial_seperator = "&";
}
if(is_numeric($category_id) && ($category_id > 0)) {
$product_url = get_option('product_list_url').$initial_seperator."category=".$category_id."&product_id=".$product_id;
} else {
$product_url = get_option('product_list_url').$initial_seperator."product_id=".$product_id;
}
return $product_url;
}
To apply the patch, simply copy and paste the above function into product_display_functions.php in WP e-Commerce 3.5.1. This file should be located in the root folder of your WP e-Commerce plugin.
Conclusion
Finally, keep in mind, I am no expert on the WP e-Commerce plugin. I was in the same boat as everyone else until I started digging through the code of the stable and beta release versions. Therefore, I hope this post will be of service to others out there; however, beyond this patch, I probably don’t know any more about the plugin’s code than you do.


You rock
Thank you so much for that fix. You’re a genius!
You’re the best, thank you so much. I worried I’d paid for a horribly broken cart!
you’re a lifesaver, one of my clients bought the gold version of the plugin, which includes this function call, and was ready to demand a full refund for the site I’d spent hours building because of this stupid stupid bug. grrrr.
thanks!
Thanxs a lot man i am going to purchase the plugin and is better to be aware!
omg!! Thank you!! you rock!! it really works!! aww.. ♥ I just bought the Gold Cart and I got the same error but thank you for the help♥ o(^-^ )oo(^-^)o( ^-^)o
Thank you so much for solving our problem! I had spent a day fighting the error above before I found you…you make me really happy.
You rock!!!
My version of wp e-commerce has the required function so I’m leaving it alone right now, however, after inputting the API Key I do not have a ‘grid view’ set up option in the Gold Cart Options area?
I have unzipped the grid-view archive inside the gold_cart_files folder but nothing,
any ideas anyone?
Hi Guys.
The most stable version at this precise moment is available from the wordpress extend site. It is the Development Version.
WP e-Commerce Development Version
http://wordpress.org/extend/plugins/wp-e-commerce/download/
This is stable and has many optimizations, fixes, and features since WP e-Commerce 3.5.1 and I would recommend updating.
Ciao,
Dan