WP ECommerce Category URL Caching

So…if you’re using WP ECommerce version 3.7.4 you’ve probably noticed that if you have a category set up and then change the name of that category later on, the URL is not updated. If you’re using the categories widget in your sidebar, this can be somewhat of an issue as the link there will not work for the category that you’ve edited the name of.

This has been addressed in version 3.7.5 but if you’re still experiencing issues with version 3.7.5 this fix will also work for that version.

The problem is that the category URL caching is not functioning correctly and therefore you get the issue of the URLs not updating. So…we’ll fix it!

The easy way out: You can download a new copy of “wp-shopping-cart.php” here and replace the one on your server with this one. (Make sure to make a backup of your original, just in case!)

If you’re downloading this copy for the fix for version 3.7.5 , you’ll want to edit the file to reflect that it’s version 3.7.5 correctly, as this file was taken from 3.7.4.

Open the file and on or around lines 6 and 19 you’ll see these areas:

Version: 3.7.4
define('WPSC_PRESENTABLE_VERSION', '3.7.4');

Make sure to change those version numbers to “3.7.5″ so that your plugins dashboard will reflect the correct version.

If you’d like to fix it manually, then you will want to navigate (on your server) to “wp-content/plugins/wp-e-commerce/wp-shopping-cart.php”

There are several places to work on in this file. The first is on or around line 261 and you should see this line:

global $wpsc_cart,  $wpsc_theme_path, $wpsc_theme_url, $wpsc_category_url_cache;

You want to remove the “$wpsc_category_url_cache” bit, so that it looks like this:

global $wpsc_cart,  $wpsc_theme_path, $wpsc_theme_url;

The next place to look will be on or around line 298 and you should see this line:

$GLOBALS['wpsc_category_url_cache'] = get_option('wpsc_category_url_cache');

You can just comment out this entire line like this:

//$GLOBALS['wpsc_category_url_cache'] = get_option('wpsc_category_url_cache');

Next, you will look on or around line 309 and you’ll see this line (like the first one above):

global $wpdb, $wpsc_start_time, $wpsc_cart, $wpsc_category_url_cache;

Take out the caching bit like instructed above so that it looks like this:

global $wpdb, $wpsc_start_time, $wpsc_cart;

The last place you’ll edit is on or around line 317, and there you should see this line:

update_option('wpsc_category_url_cache', $wpsc_category_url_cache);

And you will just comment out this entire line so that it looks like this:

//update_option('wpsc_category_url_cache', $wpsc_category_url_cache);

That should be it! Just clear your broswer cache, refresh page and your WP ECommerce category URLs should be updated and working properly.

So…until next time…

Tags: , , , ,

One Comment

Leave a comment
  1. rfrohnerath Nov. 23, 2009 at 2:06 pm #

    Thanks, Shayne. Modifying the file as suggested solved the problem.

Leave a Reply