WordPress WP-ecommerce Two Images Hack on Single Product Page

Have you ever thought about displaying two or more images on your wpsc-single_product.php file instead of just one?

If you need to display more than one image, you just have to add this code to the single product page, changing values for LIMIT on the SQL query as you want.

Probably you will want to comment the thumbnail original code. It is right after the line with this conditional

<?php if ( wpsc_the_product_thumbnail()) : ?>

Well, here goes the hack.

$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME) or die ("Could not select database, check you wp-config file" . mysql_error());
$sql = "select guid from wp_posts where post_type='attachment' and post_mime_type='image/jpeg' and post_parent=".wpsc_the_product_id();
$sql .= " ORDER BY ID ";
$sql .= " LIMIT 2 ";
$qry = mysql_query($sql);
$nrt = mysql_num_rows($qry);
while($rs = mysql_fetch_array($qry)):
    <a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo $rs[0]; ?>">
            <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo $rs[0]; ?>" width="280"/>

  1. Leave a comment

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: