Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

A Random Product Button!

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 12-26-2006, 03:11 AM
 
jordan0 jordan0 is offline
 

Advanced Member
  
Join Date: Oct 2003
Location: San Francisco, CA
Posts: 77
 

Arrow A Random Product Button!

Simple! I just spent the last hour figuring out how to do something that I was surprised not to have found on the forums.

I made a button that when clicked, sends the customer to a random product page. Thats it. Dead simple.

All you have to do is make a new file, randomProduct.php in your xcart root dir containing the following:

Code:
<?php require "./auth.php"; $rnd = rand(); $random_product = func_query("SELECT $sql_tbl[products].productid FROM $sql_tbl[products] WHERE $sql_tbl[products].forsale='Y' ORDER BY RAND(NOW()+$rnd) LIMIT 1"); header("Location: product.php?productid=".$random_product[0]['productid']); ?>

And then wherever you would like the button on your site, use the following in any .tpl:

Code:
<a href="{$xcart_web_dir}/randomProduct.php">Random Product!</a>

This works on my 4.0.18 install. Enjoy.
__________________
Jordan Sitkin
http://www.kitkraft.biz
X-Cart 4.0.18 [unix]
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:40 PM.

   

 
X-Cart forums © 2001-2020