These instructions will show you how to easily add a "New_Arrivals"
category to your store. Customers can easily see the latest additions
to your store.
1) in commerce.setup.db (library folder), add this section near the top:
#######################################
# New arrivals selection variables by Chris Costa #
#######################################
$sc_show_new_arrivals = "yes";
$sc_new_arrival_number = "$sc_db_max_rows_returned";
You can turn this feature on or off with the $sc_show_new_arrivals varible set
to "yes" or "no".
You can set the number of newest products returned by setting the
$sc_new_arrival_number variable to a number instead, however
THIS NUMBER CANNOT BE MORE THAN THE NUMBER OF PRODUCTS PER PAGE
SET IN THE MANAGER PROGRAM.
2) in commerce_db_lib.pl file (library folder), find this line:
if ($row_count > $sc_db_max_rows_returned)
And add this in right ABOVE that line:
# Hack to allow new arrivals listing in categories by Chris Costa
# Called with ?product=new_arrivals
if (($row_count == 0) && ($form_data{'product'} =~ /new.arrivals/ig) && ($sc_show_new_arrivals eq "yes")){
print "
NEW ARRIVALS
Now listing the last $sc_new_arrival_number products added to this store:
";
open(NEWBIES, "$sc_data_file_path") ||
&file_open_error("$sc_data_file_path",
"Read Database",__FILE__,__LINE__);
my (@new) = ;
close (NEWBIES);
@new = sort{$a<=>$b}(@new);
$row_count = $sc_new_arrival_number;
do{
my ($taken) = pop (@new);
push (@database_rows, $taken);
$sc_new_arrival_number --;
} until ($sc_new_arrival_number eq "0");
}
#end hack for new arrivals Chris Costa
That's it! Now you can place a link on your store pages to a category called "New_Arrivals".
Clicking the link will list the latest additions to your store.
Regards,
Chris Costa
More great hacks and modifications available at:
http://www.wildaboutbeads.com/hosting/scripts
For CommerceSQL, Try this BETA - let me know if it works well for you:
In index.cgi
add this near the other variables near the top:
#######################################
# New arrivals selection variables by Chris Costa #
#######################################
$sc_show_new_arrivals = "yes";
$sc_new_arrival_number = "$sc_db_max_rows_returned";
You can turn this feature on or off with the $sc_show_new_arrivals varible set
to "yes" or "no".
and lower in the index.cgi file find this line:
if ($row_count > $sc_db_max_rows_returned)
And add this in right ABOVE that line:
# Hack to allow new arrivals listing in categories by Chris Costa
# Called with ?product=new_arrivals
if (($row_count == 0) && ($form_data{'product'} =~ /new.arrivals/ig) && ($sc_show_new_arrivals eq "yes")){
print "NEW ARRIVALS
Now listing the last $sc_new_arrival_number products added to this store:
";
$mysql_full_query_expr = "SELECT * ".
"FROM $sc_mysql_prd_table ";
$dbh = DBI->connect ($sc_mysql_dsn, $sc_mysql_user_name, $sc_mysql_password,
{ RaiseError => 0, PrintError => 0})
or $mysql_error_message = "MySQL Error: Could not connect to $sc_mysql_dsn";
if ($mysql_error_message ne ""){
&update_error_log($mysql_error_message, __FILE__, __LINE__);
} else {
$sth = $dbh->prepare ("$mysql_full_query_expr");
$sth->execute ();
while( @fields = $sth->fetchrow_array () ){
push(@new, join("\|", @fields));
} # End of while
$sth->finish ();
$dbh->disconnect ();
}
@new = sort{$a<=>$b}(@new);
$row_count = $sc_new_arrival_number;
do{
my ($taken) = pop (@new);
push (@database_rows, $taken);
$sc_new_arrival_number --;
} until ($sc_new_arrival_number eq "0");
}
#end hack for new arrivals Chris Costa
That's it! Now you can place a link on your store pages to a category called "New_Arrivals".
Clicking the link will list the latest additions to your store.
Regards,
Chris Costa
More great hacks and modifications available at:
http://www.wildaboutbeads.com/hosting/scripts