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

Random Products - 2 Products Per Row - In Place of Featured

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 12-09-2002, 04:28 PM
 
okdpminc okdpminc is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 74
 

Default Random Products - 2 Products Per Row - In Place of Featured

I was wondering if anybody had ever replaced the featured products on the home page with a random list of 6-8 products, two per row? My thinking is it would make the site look less static. Anyone know how to achieve this?
__________________
- okdpm

X-Cart Gold Version: 3.5.1

Things are more like they are now than they have ever been before...
Reply With Quote
  #2  
Old 12-10-2002, 07:22 AM
 
DogTags DogTags is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 96
 

Default

I don't have a solution, but you're right. Random products would be a great feature.
Reply With Quote
  #3  
Old 12-10-2002, 08:33 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

The code must be in there already as it uses it for the recommended products.
__________________
ex x-cart guru
Reply With Quote
  #4  
Old 12-10-2002, 01:57 PM
 
okdpminc okdpminc is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 74
 

Default

I'm not a programmer by any means, or I'd be happy to dig in and find it. I was just hoping somebody had already done this, or would find it an interesting challenge and share the code with all of us.
__________________
- okdpm

X-Cart Gold Version: 3.5.1

Things are more like they are now than they have ever been before...
Reply With Quote
  #5  
Old 12-10-2002, 04:04 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Code:
$f_products = func_query("select $sql_tbl[products].*, min($sql_tbl[pricing].price) as price from $sql_tbl[products], $sql_tbl[featured_products], $sql_tbl[pricing], $sql_tbl[categories] where $sql_tbl[products].productid=$sql_tbl[featured_products].productid and $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid AND ($sql_tbl[categories].membership='$membership' OR $sql_tbl[categories].membership='') and $sql_tbl[products].forsale='Y' and $sql_tbl[products].avail>0 and $sql_tbl[featured_products].avail='Y' and $sql_tbl[pricing].quantity=1 AND $sql_tbl[featured_products].categoryid='$f_cat' and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') group by $sql_tbl[products].productid order by $sql_tbl[featured_products].product_order");

Whew what a SQL query

http://www.php.net/manual/en/printwn/function.rand.php

Little mix of rand(); and some modified or added SQL queries and its possible.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #6  
Old 12-11-2002, 09:15 AM
 
okdpminc okdpminc is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 74
 

Default

Boomer,

Wow! Now I see why I'm not a programmer. Is your code snippit what we need to accomplish this, and if so, where would we paste this in at??
__________________
- okdpm

X-Cart Gold Version: 3.5.1

Things are more like they are now than they have ever been before...
Reply With Quote
  #7  
Old 12-11-2002, 10:38 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

this is the current sql not the new stuff. the new stuff will be more complex than this.

need to add this into customer/home.php

Code:
include "./random.php";

This will bring in a list of random products.
Then we need to create this random.php in customer/ and is based on reccomends.php

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

You will then need to include this in the home page by modifying the appropriate templates.
__________________
ex x-cart guru
Reply With Quote
  #8  
Old 12-11-2002, 07:30 PM
 
okdpminc okdpminc is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 74
 

Default

funkydunk,

Thanks a million for the code. I made the change to my customer/home.php and created the customer/random.php, but nothing changed. I still have the same 'Featured Products' showing up as they always have.

I see where you said to 'include this in the home page by modifying the appropriate templates'. Would you please explain this in more detail (i.e. which templates and what exactly to add), as not only am I not a programmer, I am VERY new to X-Cart as well.

Looking forward to hearing from you.
__________________
- okdpm

X-Cart Gold Version: 3.5.1

Things are more like they are now than they have ever been before...
Reply With Quote
  #9  
Old 12-12-2002, 05:05 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

PLEASE BACKUP ALL FILES BEFOREHAND JUST IN CASE!!

I haven't tested this but I would change skin1/customer/home_main.tpl as follows:

from:

{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcome.tpl" f_products=$f_products}

to:
Code:
{elseif $main eq "catalog" and $current_category.category eq ""} {include file="customer/main/welcome.tpl" randoms=$randoms}
to replace the featured products

Then amend customer/main/welcome.tpl to:

Code:
{* $Id: welcome.tpl,v 1.21 2002/09/10 12:36:34 zorg Exp $ *} {if ($active_modules.Greet_Visitor ne "") AND ($smarty.cookies.GreetingCookie ne "")} <h3>{$lng.lbl_welcome_back}, {$smarty.cookies.GreetingCookie} </h3> {else} <h3>{$lng.lbl_welcome_to} { $config.Company.company_name }</h3> {/if} {$lng.txt_welcome} {if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"} {include file="modules/Bestsellers/bestsellers.tpl"} {/if} {include file="customer/main/randoms.tpl" randoms=$randoms}

then creat a new template
customer/main/randoms.tpl

Code:
{* $Id: randoms.tpl,v 1.13 2002/05/20 06:55:20 lucky Exp $ *} {capture name=dialog} {include file="customer/main/products.tpl" products=$randoms} {/capture} {include file="dialog.tpl" title=$lng.lbl_random_products content=$smarty.capture.dialog extra="width=100%"}

then creat a new lbl in the languages area named lbl_random_products with the value that y9ou want to have shown in the top of the box.
__________________
ex x-cart guru
Reply With Quote
  #10  
Old 12-12-2002, 05:15 PM
 
okdpminc okdpminc is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 74
 

Default

funkydunk,

Wow, you're good....you're FUNKY good!

The only problem is that my random products have "Enter your price !" instead of "Our price: $". This kind of needs addressed as we don't want the customer thinking they can pick their own price.

Any ideas on what the last tweak to the puzzle might be?
__________________
- okdpm

X-Cart Gold Version: 3.5.1

Things are more like they are now than they have ever been before...
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 12:02 PM.

   

 
X-Cart forums © 2001-2020