I am sure that anyone else trying to use WP e-commerce would join me in lamenting the lack and quality of the documentation for the plugin. That being said, I’m still loving the plugin for its relative ease of set-up and easy integration with the powerful content management features of WordPress.
The basic plugin contains almost everything you need for a basic store, but for just $40 extra you get the Gold Cart plugin with a few extras. In my case I was hunting down the ability to have multiple images associated with each product in my store. Additionally I am more than happy (and I think my client will be as well) to send a small amount of money in the direction of the developers.
Within a few minutes I had the upgrade installed and had uploaded my first set of multiple images to some products. Easy! But then trying to get them displayed within my product listings was not so obvious.
The plugin natively includes the ability to display the first product image and a function (apparently – as it didn’t work for me) to display any further images in a gallery with a lightbox script. However I didn’t want to use a Lightbox, or give up too much of the code generation for my pages to the plugin.
After a few minutes of Googling for a solution, I decided it was going to be a lot quicker to just write my own PHP function to query the database for all the images. Voila:
function get_all_images($product) {
global $wpdb;
return $wpdb->get_results( "SELECT image FROM wp_wpsc_product_images WHERE product_id=$product ORDER BY image_order ASC" );
}
Just pass this function the Product ID that you are interested in and it will return an object with all the images for you to play around with in PHP. It should be noted that it only returns the filename and extension, so you will have to prepend the path to the file.