SiteKickr Web Development

WP E-Commerce Gold Cart Product Gallery – no lightbox

I was pumped to upgrade to the Gold Cart plugin for WP E-Commerce today, but was disappointed to find that the product gallery lightboxes simply don't function. This was a disappointment, as it was the primary reason for the upgrade.

When clicking on a Product Thumbnail in the Gallery, nothing happens. A deeper look at the WP E-Commerce JavaScript reveals this event handler, which effectively cancels any actions from taking place by clicking a thumbnail:

jQuery('.attachment-gold-thumbnails').click(function(){
	jQuery(this).parents('.imagecol:first').find('.product_image').attr('src', jQuery(this).parent().attr('rev'));
	jQuery(this).parents('.imagecol:first').find('.product_image').parent('a:first').attr('href', jQuery(this).parent().attr('href'));
	return false;
});

So, what can we do. If we alter the JavaScript file, we leave ourselves vulnerable to any upgrades that will simply overwrite our changes. Same deal with modifying the gold_shpcrt_display_gallery function to remove the attachment-gold-thumbnails class.

I rather "hacky" solution that I employed was to use a little string manipulation to strip out the attachment-gold-thumbnails class from any <a> tags present in the function output. This had no effect on the display, but did solve the issue. In your customized version of the wpsc-single_product.php or wpsc-products_page.php, make the following adjustment:

<?php
if ( function_exists( 'gold_shpcrt_display_gallery' ) )
    echo str_replace('attachment-gold-thumbnails', '', gold_shpcrt_display_gallery( wpsc_the_product_id() ));
?>