Jump to content

Cool new feature.


Guest MrBigBargin

Recommended Posts

Guest MrBigBargin

Hey all, I been trying to to figure this one out for a while now and it just hit me tonight.

All my products are listed with a mark down price and the regular retail price. So the sale items box always remained the same. I wanted the sale items box to show random items though.

So I got playing with the code and figured it out.

If you want your sale items box to populate with random products with each page load simply open includes/boxes/saleItems.inc.php

Now find this line:

$saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$config['dbprefix']."CubeCart_inventory where sale_price > 0 ORDER BY saving ASC",$config['noSaleBoxItems']);

It's the very first line of code.

Now select that line and replace it with this:

mt_srand ((double) microtime() * 1000000);

$seed = mt_rand(1,10000);

if(isset($_GET['catId'])){

$whereClause = "WHERE cat_id=".$db->mySQLSafe($_GET['catId']);

}

$saleItems = $db->select("SELECT name, productId, price, sale_price, price - sale_price as saving FROM ".$config['dbprefix']."CubeCart_inventory where sale_price > 0 ORDER BY RAND(".$seed.") LIMIT 10");

NOTE: Where it says "LIMIT 10" above, change the number 10 to however many products you want listed in the sale items box.

You can see a live example of this working here:

http://www.bigbarginbuys.com

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...