View Single Post
  #18  
Old 10-23-2006, 03:17 PM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Default Re: Best Sellers for the Month Only

I changed this for xcart 4.1.3

shopcart/bestsellers_month.php

<?
$start_date = strtotime("-1 month"); # LAST MONTH PRODUCTS
$end_date = strtotime("now"); # TODAY - NOW
$amount_prod_to_show = '6'; # AMOUNT OF PRODUCTS TO SHOW
$query = "SELECT $sql_tbl[products].*, $sql_tbl[pricing].*, $sql_tbl[order_details].productid, $sql_tbl[order_details].orderid, $sql_tbl[orders].orderid, $sql_tbl[orders].date, count($sql_tbl[order_details].productid) as sold FROM $sql_tbl[pricing], $sql_tbl[products], $sql_tbl[orders], $sql_tbl[order_details] WHERE ($sql_tbl[orders].status='C' OR $sql_tbl[orders].status='P') AND $sql_tbl[orders].date > '$start_date' AND $sql_tbl[orders].date < '$end_date' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid AND $sql_tbl[products].productid=$sql_tbl[order_details].productid AND $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].avail>0 GROUP BY $sql_tbl[order_details].productid ORDER BY sold DESC LIMIT $amount_prod_to_show";
$month_sellers = func_query($query);
$smarty->assign("month_sellers",$month_sellers);
?>

In the shopcart/home.php add

require "./bestsellers_month.php";

In the shopcart/skin1/customer/main/welcome.tpl add

{if $month_sellers ne ""}
{include file="modules/Bestsellers/bestsellers_month.tpl" products=$month_sellers featured="Y"}
<br />{/if}

Also add the above if you want it to be displayed in your subcategories to shopcart/skin1/customer/main/subcategories.tpl

I also made in shopcart/skin1/modules/bestsellers/bestsellers_month.tpl file which is:

bestsellers_month.tpl

{if $month_sellers}
{capture name=bestsellers}
<TABLE border="0" cellpadding="0" cellspacing="0">
<tr>
{foreach from=$month_sellers item=bestseller}
<TD width="100" align="center" valign="top">
<div align="center">{if $config.Bestsellers.bestsellers_thumbnails eq "Y"} <a href="product.php?productid={$bestseller.productid }&cat={$cat}&bestseller">{include file="product_thumbnail.tpl" productid=$bestseller.productid image_x=50 product=$bestseller.product alt=$bestseller.fulldescr|replace:"":""}</a>
<br />
{/if}
<b><a href="product.php?productid={$bestseller.productid }&amp;cat={$cat}&amp;bestseller">{$bestseller.prod uct}</a></b><br />
{$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.price}<br />
</div></td>
<TD width="10"></TD>
{/foreach}
</tr>
</table>
{/capture}
{include file="dialog.tpl" title="This Months Hottest Sellers!" content=$smarty.capture.bestsellers extra='width="100%"'}
{/if}

You can see the finished product at http://www.theshisha.com/shopcart/home.php?cat=255

It will also display at the top of every categories, to see this go to http://www.theshisha.com/shopcart/home.php?cat=272
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote