X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Random Products - 2 Products Per Row - In Place of Featured (https://forum.x-cart.com/showthread.php?t=914)

Jonny 01-12-2003 09:28 AM

Thanks m8

We are running on www.overclock.co.uk already but just havent implemented xcart as yet.

i am running here on a complete wireless Lan, it is amazing lol no wires.

we should be getting some NetGear stuff in soon aswell

Jonny.

dfaa 01-16-2003 11:42 PM

Enter Your Price
 
:oops: Hi have installed these scripts among ther script and it all work great, but on The Enter your price,(under feature) i want to display the actual price , how can this bee done i have tried to modify the products.tpl and enter

<font class=TableCenterProductTitleOrange>{$lng.lbl_ente r_your_price}

to

<font class=TableCenterProductTitleOrange>{$products[product].price}

but it only displays 0.00

Can someone help me out here

http://data.eol.no

funkydunk 01-16-2003 11:54 PM

Try this new and revised code for the randoms.php file. It now joins the product table with the pricing table - should have been in there really to start with..sorry everyone :)

Code:

removed cos it was wrong!!

dfaa 01-17-2003 12:17 AM

Error after new randoms.php
 
Hi there must be something wrong with the new code. ir runs an SQL eror.

INVALID SQL: 1052 : Column: 'productid' in where clause is ambiguous
SQL QUERY FAILURE: SELECT * FROM xcart_products,xcart_pricing WHERE forsale='Y' AND avail>0 AND xcart_products.productid=xcart_pricing.productid AND (productid='8' OR productid='47' OR productid='61' OR productid='54' OR productid='40' OR productid='34' OR productid='11' OR productid='42' OR productid='60' OR productid='57')

funkydunk 01-17-2003 12:34 AM

okay - sorry..amateur mistake :oops:

amend the code to:

Code:

<?
// give it all available products to work with
$products_id = func_query("SELECT productid FROM $sql_tbl[products] WHERE forsale='Y' and avail>0");

// set the variables
$str = "";
$numberRandoms=10; // set this to how many you want to show

// the witchcraft
$query_condition = " AND (";
srand((double)microtime()*1000000);
$rnd = rand(0, count($products_id)-1);
$query_condition .= "$sql_tbl[products].productid='".$products_id[$rnd][productid]."'";
for($i = 0; $i < $numberRandoms - 1; $i++) {
        $rnd = rand(0, count($products_id)-1);
        if (!ereg("'".$products_id[$rnd][productid]."'", $query_condition)) {
                  $query_condition .= " OR $sql_tbl[products].productid='".$products_id[$rnd][productid]."'";
          }
}
// finish off the query
    $query_condition .= ")";

// runs the new random query against the database
    // $query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND avail>0".$query_condition;
   
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid".$query_condition;

// give the product array to smarty to make it available sitewide.
$randoms = func_query($query);
$smarty->assign("randoms",$randoms);
?>


Cameron 03-02-2003 09:49 PM

Funky, this code is great and your instructions are GREAT! I just read through the thread, followed the steps, used the revised random.php code and it works perfect.

But of course, I have a question. ;-)

Sometimes it shows 7, 8 or 9 products. I only have 50 products added so far, so I'm thinking that once I get all 300 or so added in that it will always show 10. If not, I really don't care, because just having it randomize is SO COOL!

Thanks,
Cameron

funkydunk 03-02-2003 10:18 PM

Thanks.

It should be showing 10 products though. :?

Cameron 03-02-2003 10:58 PM

No worries. I realized that I like having 8 products there, anyway, so I changed the value to 8. Sometimes it shows 6 or 7, but I think it is actually cool so that people coming back see a pretty dynamic page. Google spiders will probalby love it, too. :D

Cameron

funkydunk 03-02-2003 11:14 PM

cant remember why I wrote this now :? , but very useful instead of featured products and to have a different looking front page every visit.

okdpminc 03-03-2003 07:05 PM

Funky, You wrote it because I asked if anybody had this feature, and you came in and knocked it out in no time. Mine also comes up one short on occasion, but it's no big deal at all. Thanks a MILLION for the great code! :)


All times are GMT -8. The time now is 11:29 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.