WP e-Commerce List Products and Images Hack

Important note: It works only for WP-ecommerce 3.6. For later versions, WP-ecommerce database has changed, so you will need the new hack.

You should also take a look on my WP e-Commerce Product Showroom Plugin, a configurable widget and a evolution of the code bellow.

If you are working with WP e-Commerce Plugin, with the code bellow, you will be able to get a kind of product list, with images, anywhere you want on your site.

Just change your database information, and the LIMIT on mysqlquery, and no more stress…

Good look, may the force be with you.

   $conn = mysql_connect("SERVER", "USER", "PASS"); 
    mysql_select_db("DATABASE") or die ("Could not select database" . mysql_error());
    // if you are note sure about the value of $wp_table_prefix, perform a search for this
    // text on your site, the usual value is "wp_" or something
    $sql = "SELECT products.id,products.name,products.description,products.image,product_category.category_id ";
    $sql .= "FROM ".$wp_table_prefix."wpsc_product_list AS products ";
    $sql .= "LEFT JOIN ".$wp_table_prefix."wpsc_item_category_assoc AS product_category ON ";
    $sql .= "products.id=product_category.product_id ";
    $sql .= "WHERE products.publish=1 AND products.active=1 ORDER BY products.name LIMIT 3";
    $qry = mysql_query($sql);
    $nrt = mysql_num_rows($qry);
    while($rs = mysql_fetch_array($qry)):          
                        <li><a href="<?php echo wpsc_product_url($rs[0]); ?>">
                        <img src="index.php?image_id={<?=$rs[3]?>}"></a>
                        <a href="<?php echo wpsc_product_url($rs[0]); ?>"><?=$rs[1];?></a></li>   


  1. #1 by benn on February 16, 2011 - 11:38 am

    Thanks so much for this!! ill never pay for gold now 🙂

    • #2 by Alvaro Neto on February 16, 2011 - 12:22 pm

      You’re welcome. If you want to suggest other WP Ecommerce hacks, please let me know 😉

  2. #3 by Max Leong on February 18, 2011 - 8:02 am

    can you try hack wp-ecommerce product images? hope can have multiple images for each product but now only can have one image per product…Say No to GOLD CART!

    • #4 by Alvaro Neto on February 18, 2011 - 11:04 am

      Hi Max, It’s a very good idea! I’ll try to work on it. I can’t tell you exactly when, cos I write the blog in my free time, but it’s on my schedule and I’ll let you know when it’s done. Thank you for your visit and for your idea.

      • #5 by Mauricio on March 7, 2011 - 9:11 pm

        If you can do that.. it would be awesome… please let me know.. what about a “previous / next buttons” inside the single product.

      • #6 by Alvaro Neto on March 9, 2011 - 8:50 pm

        Ok, I’ll try to take a look on it asap, but as I told you, I work im my free time, anyway, I’m on it 😉

  1. The New WP e-Commerce List Products and Images Hack « It works on WordPress

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: