Ikool’s Blogbed

Incorrect URLs for images, css and js files in Products page of WP e-commerce plugin

After adding a few products with photos to one of the newly defined categories and following the steps as stated in Tips on how to reset default category in WP e-commerce plugin’s admin panel, I am able to see the products listed in the page but none of them with the uploaded photos. This really puzzled me for a while, and I even debugged the code for sometime. However, it turns out e-commerce plugin producing incorrect URLs for images, css and js files included by the plugin, these URLs are in the format of system directory, such as C:\tools\wordpress-2.5.1\wp-content\….. Once the root cause of the issue is found, the fix is a bit easier.

Here I am providing the fixes so that folks who have the similar issues will benefit from it.

  1. Open up wp-shopping-cart.php and go to line 30 or do a search to find the following line:
    define('WPSC_URL', str_replace(ABSPATH, $siteurl.'/', WPSC_FILE_PATH));
    Note that ABSPATH is formatted with a trailing ‘/’, therefore, on different operating systems, this may give you different results. For example, on microsoft windows, this PHP string replacement call will fail and that’s what I see
  2. Comment out this line, and we will add the following lines to get the correct WPSC_URL
    define('WPSC_FOLDER', dirname(plugin_basename(__FILE__)));
    define('WPSC_URL', get_option('siteurl').'/wp-content/plugins/' . WPSC_FOLDER);

That’s it. I am sure this will also fix many other issues, for example, product photos will be display edcorrectly, in your admin’se-commerce panel, you should have the correct look and feel instead like this one. Now you can even edit product categories and products, without this fix you won’t be able to do so.

Here is my wordpress settings: WordPress 2.5.1 with NextGen Gallery and WP e-commerce (3.6.6) plugins

Folks, Please leave me a note/comment if you think my article is helpful 🙂

UPDATE: PLEASE MAKE SURE SINGLE QUOTE IS USED IN define for BOTH CONSTANTS and VALUES!!!

Advertisements

June 15, 2008 - Posted by | Technology, Wordpress Tips, WP E-Commerce | , , , , , , , , ,

23 Comments »

  1. Your edits as listed above still don’t work.

    If someone searches for the first line they won’t find it because of the double quotes. The search line (although it should be line 30 – as you say):

    define(‘WPSC_URL’, str_replace(ABSPATH, $siteurl.”/”, WPSC_FILE_PATH));

    The replacement lines should be:
    // define(‘WPSC_URL’, str_replace(ABSPATH, $siteurl.”/”, WPSC_FILE_PATH));
    define(‘WPSC_FOLDER’, dirname(plugin_basename(__FILE__)));
    define(‘WPSC_URL’, get_option(‘siteurl’).’/wp-content/plugins/’ . WPSC_FOLDER);

    Comment by aces1 | June 17, 2008 | Reply

  2. Finally got that single quote issue fixed in the above lines

    Comment by ikool | June 17, 2008 | Reply

  3. Aces1, thanks for pointing it out

    Comment by ikool | June 17, 2008 | Reply

  4. Aces1 & ikool, I patched my install with Aces1’s lines, i get the following:

    Warning: Division by zero in mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php on line 33

    Warning: Division by zero in mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php on line 33

    Warning: Division by zero in mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php on line 33

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php:33) in mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php on line 137

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php:33) in mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php on line 137

    Warning: Cannot modify header information – headers already sent by (output started at mydomain/wp-content/plugins/wp-shopping-cart/wp-shopping-cart.php:33) in mydomain/wp-includes/pluggable.php on line 694

    thanks for the patches, hope this is useful!

    Comment by tevo | June 17, 2008 | Reply

  5. tevo,
    Please re-do it. The cause for this is the single quote which is converted to another char which PHP treats differently. After using html “code” tag it should work now. Sorry for the mistake. I just started blogging for a week, guess it will get better

    Comment by ikool | June 17, 2008 | Reply

  6. my bad, should’ve typed the lines by hand!!! quotation marks were being changed.

    Comment by tevo | June 17, 2008 | Reply

  7. sadly this fix hasn’t worked for me, i still can’t see or switch to subcategories of the products category that i created.

    Comment by tevo | June 17, 2008 | Reply

  8. I guess you have other issues even after fixing the URLs. By the way, what kind of platform you are using?

    Comment by ikool | June 17, 2008 | Reply

  9. Ubuntu 7.10 – Apache 2.2, could it be something to do with php config perhaps?

    Comment by tevo | June 18, 2008 | Reply

  10. wordpress-2.5.1 and wp-e-commerce-3.6.6

    Comment by tevo | June 18, 2008 | Reply

  11. what do you mean by “i still can’t see or switch to subcategories of the products category”, are you talking about something in the “product group” page?

    Comment by ikool | June 18, 2008 | Reply

  12. hi, thanks for taking the time,.. in version 3.5.1, the products page displays an html list of categories and sub-categories at the top of the products page, which i can click on to navigate the categories and products, but when i upgraded to version 3.6.6 this list has disappeared.

    when i turn styles off (firefox), there is a message saying “Loading…”

    Comment by tevo | June 18, 2008 | Reply

  13. when i turn styles off (firefox), there is a message saying “Loading…” in place of the categories list, to be more exact

    Comment by tevo | June 18, 2008 | Reply

  14. I am seeing the changes work for you somehow. But it seems that UI of V 3.6.6 is different from previous version. Bear me for any mistakes since I didn’t try any previous version.
    I am assuming you are talking about the category links on “Products page”. I didn’t see them in my env, not sure if they remove the feature or not, but I am assuming you can add it.

    By the way, is 3.5.1 better than 3.6.6? or any other previous versions?

    Comment by ikool | June 18, 2008 | Reply

  15. yes you’re right:- i’m talking about the products page that is rendered to the browser when a user clicks on the products page link. i’ve just been looking through the shop settings of version 3.5.1 which i currently have installed and i see there is an option to embed the categories with – , I assume this is the feature you’re talking about being missing in 3.6.6? i’ll try re-installing 3.6.6 and just dropping that into one of my pages and see what happens. 😉

    ….maybe i need to wigetize my theme!! just found a cool link – http://automattic.com/code/widgets/api/

    Comment by tevo | June 18, 2008 | Reply

  16. oops tags got blitzed

    <?php show_cats_brands(); ?>

    Comment by tevo | June 18, 2008 | Reply

  17. […] of unable to update Product details in WP e-commerce After fixing some issues (see Incorrect URLs for images, css and js files in Products page of WP e-commerce plugin, Fix of Settings menu on WP e-commerce’s Products admin page and Tips on display categories in WP […]

    Pingback by Fix of unable to update Product details in WP e-commerce « Ikool’s Blogbed | June 24, 2008 | Reply

  18. The replacement lines in Entry #1 did not work for me!
    The following lines did (note the use of “” and ”)
    define(“WPSC_FOLDER”, dirname(plugin_basename(__FILE__)));
    define(“WPSC_URL”, get_option(’siteurl’).”/wp-content/plugins/” . WPSC_FOLDER);

    Comment by TexMarlowe | July 6, 2008 | Reply

  19. The above was my first post anywhere, hence the ”) error, so I’ll try it this way— (note the use of Double Quotes and Single Quotes)

    Comment by TexMarlowe | July 6, 2008 | Reply

  20. The second “define” line did not work after all, DOOH!, but by changing “get_option(’siteurl’)” to the variable “$siteurl” defined a few lines above in the “wp-shopping-cart.php” file, the following line did work…
    define(“WPSC_URL”,$siteurl.”/wp-content/plugins/” . WPSC_FOLDER);

    Comment by TexMarlowe | July 6, 2008 | Reply

  21. Please make sure that these lines are using single/double quotes for CONSTANTS and VALUES, for some reasons wordpress made changes at backend, you may have to change whatever “quotes” you copied from this page and change them to single/double quotes if it doesn’t work

    Comment by ikool | July 6, 2008 | Reply

  22. Hi, I have been reading all these posts as I have a problem in that I have products in categories (the products even show on the left of my site, images uploaded etc) BUT, when you click on them, there isn’t a page with an image, buy buttons etc, the page is just blank.

    I am on WordPress V. 2.6.1 Shopping cart V. 3.6.8 My code is fine for the above shopping cart php. too (I guess my new version has it already fixed) and I am on Safari…

    Any ideas? Thanks in advance for the help.

    Comment by troyters | August 25, 2008 | Reply

  23. Ikool, Hopw you dont mind a question from a newbie.

    is it possible to setup the wp-ecommerce-plugin so that the customer can add a line of text.
    Example:
    COMPANY NAME: Customer Enters this information
    Financial Accounts – £2
    Names directors – £2

    Doe this make sense.

    Thanks

    Dave

    Comment by David | January 16, 2009 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: