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

periodic bestseller (weekly/monthly/annually)

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 12-24-2006, 11:39 PM
 
inebriate inebriate is offline
 

eXpert
  
Join Date: May 2006
Posts: 301
 

Default periodic bestseller (weekly/monthly/annually)

warning: this was not tested on a live server, so please backup your xcart sql database just in case...its actually my first time playing with mysql functions but i have a programming background so was able to catch on

note: this will reset your products' sales stats and obviously you must have both the Advanced Statistics and the Bestsellers modules enabled, also products are not considered 'sold' until the order is 'processed'

in modules/Advanced_Statistics/prod_sold.php, look for
Code:
$avail_condition = ""; if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") $avail_condition = " AND $sql_tbl[products].avail>0 ";
and add below it
Code:
#START MOD #****************************************************** # PERIODIC BESTSELLER by david@fabric8d #****************************************************** # d:day # W:week # m:month # Y:year #-------------- # if you want to use a different period, change what is # inside the date() function to one of the values above, # ie: date(m) for monthly. # # also if you want to do a bi- or tri- period, multiply # it in front of the function, ie: 2 * (int)date(W) for # bi-weekly #****************************************************** $dateP = (int)date(W); $dateY = (int)date(Y); $lastupdateP = (int)func_query_first_cell("SELECT period FROM xcart_lastupdate"); if(abs($dateP-$lastupdateP) > 0) { db_query("UPDATE $sql_tbl[products] SET sales_stats=0"); db_query("UPDATE xcart_lastupdate SET period=$dateP"); db_query("UPDATE xcart_lastupdate SET year=$dateY"); } #END MOD

now in the xcart admin section, goto patch/upgrade...in the "SQL query(ies)" textbox, paste one by one each line (or together, i dont know if it will work though)
Code:
CREATE TABLE `xcart_lastupdate` (`period` INT( 2 ) NOT NULL ,`year` INT( 4 ) NOT NULL) UPDATE xcart_lastupdate SET week=51 UPDATE xcart_lastupdate SET year=2006
and apply

also, you may want to update the bestseller label (lbl_bestsellers) to reflect the period

that should be it...it should work for 4.0.x and 4.1.x
__________________
x-cart pro 4.0.18
linux
www.fabric8d.com (currently undergoing construction)
Reply With Quote
  #2  
Old 06-14-2007, 11:24 AM
 
AJ-UKRS AJ-UKRS is offline
 

Advanced Member
  
Join Date: Jan 2004
Posts: 92
 

Default Re: periodic bestseller (weekly/monthly/annually)

Will this work on 3.5.x?
__________________
X-Cart Version 4.3.x
Reply With Quote
  #3  
Old 06-15-2007, 04:57 AM
 
AJ-UKRS AJ-UKRS is offline
 

Advanced Member
  
Join Date: Jan 2004
Posts: 92
 

Default Re: periodic bestseller (weekly/monthly/annually)

anyone that can get this working on 3.5.x?
__________________
X-Cart Version 4.3.x
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 05:51 PM.

   

 
X-Cart forums © 2001-2020