Guest GoodLiteCandles Posted October 15, 2005 Share Posted October 15, 2005 Right now on my cart the featured product randomizes and a different image/item shows up each time the page changes/refreshes. What I want is to specify one featured product and have it stay there until I take it off or change it to a new item that I want featured. Is this possible? And how do I do this? Also, when I dont want a featured product at the moment do I just take it out of the index.tpl and put it back in when I want a featured product again? I'd appreciate any input you can give me. Thanks. Quote Link to comment Share on other sites More sharing options...
markscarts Posted October 15, 2005 Share Posted October 15, 2005 You're right, "featured product" actually means "random product" . . . no way to specifiy a static product without changing the code. To temporarily remove, just place the HTML comment tags ( <!-- and --> ) befor and after the Featured product variable {RANDOM_PROD} in global/index.tpl: <!-- RANDOM_PROD --> Just remove the comment tags to turn it back on. Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 15, 2005 Share Posted October 15, 2005 Is there anywhere I can change the code? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2005 Share Posted October 15, 2005 I love easy solutions! In /includes/boxes/randomProd.inc.php Insert the following "whereClause" before the DB Select line as such: ############################################################################# ## Manually specified product for "Featured Product" ## Simply put the id of the product in the variable assignment below: $whereClause = "productId = '##'"; $randProd= $db->select("SELECT name, image, productId FROM ".$glob['dbprefix']."CubeCart_inventory ".$whereClause." ORDER BY RAND(".$seed.") LIMIT 1"); You'll see an IF > THEN > ELSE statement above this that sets the whereClause...leave it alone. Put the lines between the IF block and the $randProd = lines. That will take care of it for you. :) Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 15, 2005 Share Posted October 15, 2005 MySQL Error Occured 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '= '3' ORDER BY RAND(2107) LIMIT 1' at line 1 QUERY = SELECT name, image, productId FROM CubeCart_inventory productId = '3' ORDER BY RAND(2107) LIMIT 1 That's the error I got. I copied the code exactly where you told me to. And then i changed the ## to 3. I got the 3 from the id in my view items screen. Was that correct to do? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2005 Share Posted October 15, 2005 DOH!!!! My bad. I was sleepy when I typed that. $whereClause = "WHERE productId = '##'"; Sorry :) Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 15, 2005 Share Posted October 15, 2005 Okay it doesnt give me any errors now (yay!) But it still changes the product each time I click on a category link or a specific product. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2005 Share Posted October 15, 2005 Well, in that case, just use this: $randProd= $db->select("SELECT name, image, productId FROM ".$glob['dbprefix']."CubeCart_inventory ".$whereClause); :) Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 16, 2005 Share Posted October 16, 2005 We're getting closer. That works when I open the cart and am on the homepage or when I click the homepage link. It always loads the product I specified. But when I click on each product caregory link, the Featured Product changes to a product in the link's category. Is there a way to just set up that with each link I click, the featured product stays the same. I only want one featured product. Thanks. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2005 Share Posted October 16, 2005 Hmmm....it shouldn't do that. Paste your randomProd.inc.php in a box here (you can leave off the comment header if you like). I'll look to see if there's anything out of place. :w00t: Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 16, 2005 Share Posted October 16, 2005 Thank you so much for helping me. Here's the code... <?php if(!isset($config)){ echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>"; exit; } mt_srand ((double) microtime() * 1000000); $seed = mt_rand(1,10000); if(isset($_GET['catId'])){ $whereClause = "WHERE cat_id=".$db->mySQLSafe($_GET['catId']); } else { $whereClause = "WHERE productId = '7'"; } $randProd= $db->select("SELECT name, image, productId FROM ".$glob['dbprefix']."CubeCart_inventory ".$whereClause); if($randProd==TRUE){  if(($val = prodAltLang($randProd[0]['productId'])) == TRUE){   $randProd[0]['name'] = $val['name'];   } $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/randomProd.tpl"); $box_content->assign("LANG_RANDOM_PRODUCT",$lang['front']['boxes']['featured_prod']); $box_content->assign("PRODUCT_ID",$randProd[0]['productId']); $box_content->assign("PRODUCT_NAME",$randProd[0]['name']); if(!empty($randProd[0]['image'])){  $box_content->assign("IMG_SRC","images/uploads/thumbs/thumb_".$randProd[0]['image']); } else {  $box_content->assign("IMG_SRC","skins/".$config['skinDir']."/styleImages/thumb_nophoto.gif"); } $box_content->parse("random_prod"); $box_content = $box_content->text("random_prod"); } else { $box_content = ""; } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2005 Share Posted October 16, 2005 I thought this was your problem.... if(isset($_GET['catId'])){ $whereClause = "WHERE cat_id=".$db->mySQLSafe($_GET['catId']); } else { $whereClause = ""; } ############################################################################# ## Manually specified product for "Featured Product" ## Simply put the id of the product in the variable assignment below: $whereClause = "WHERE productId = '7'"; $randProd= $db->select("SELECT name, image, productId FROM ".$glob['dbprefix']."CubeCart_inventory ".$whereClause); You weren't supposed to touch the existing if / else statement but add my code below it. I thought I was right the first time. :w00t: Quote Link to comment Share on other sites More sharing options...
Guest GoodLiteCandles Posted October 16, 2005 Share Posted October 16, 2005 *smacks head* DOH It works perfectly. Thank you so much!!!! Quote Link to comment Share on other sites More sharing options...
Guest Posted October 19, 2005 Share Posted October 19, 2005 I wanted to do this myself, so I added the code to my site. When I do, the Featured Product goes away. If I comment it out, it comes back. Any ideas what would cause that? http://www.tdbellenterprises.com/store V3.0.5 Don Bell Quote Link to comment Share on other sites More sharing options...
Guest Posted October 19, 2005 Share Posted October 19, 2005 Ok, I figure that qualifies as Idiot of the Month... I was putting in my Product Code Number, Not the ID number! It was working correctly as the Product Code is 5 digits long, and the ID numbers are in the double digits only, so it was saying, "Hey, no such product, we don't show it!" Took me a few to figure out what was happening, but I'm persistent... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.