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

Search order details by email, zipcode, and other things.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-22-2003, 02:51 AM
 
Alan Alan is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 83
 

Default Search order details by email, zipcode, and other things.

Hello all,

The altered/added code below is quite simple to understand, so if you would like to add other fields to your orders search, it's basically 1 line in each files that you have to change/add. Sorry I couldn't explain better, as I'm using my short coffee break to post this.

I added a reset button at the top of the form, FYI.

For the emails, you can put in partial matchings (ie @x-cart.com, jondoe, jondoe@x-cart, etc.). *Edit* So does your customer name string, btw.

PARTIAL CODE ONLY: look for and paste into /{your-x-cart-dir}/skin1/main/orders.tpl
Code:
{capture name=dialog} <table border=0> <form name="searchform" action="orders.php" method=get> <INPUT type=hidden name=mode value=""> <tr><td colspan=2 class=FormButton>Reset fields</td><td> <input type=reset name=clear value=Reset> </td></tr> <tr> <td height="10" class=FormButton nowrap>{$lng.lbl_order_id}</td> <td width="10" height="10"></td> <td height="10"> <input type="text" name="orderid" size="6" value="{$smarty.get.orderid}"> </td> </tr> {if $usertype ne "C"} <tr> <td height="10" class=FormButton nowrap>{$lng.lbl_customer}</td> <td width="10" height="10"></td> <td height="10"> <input type="text" name="substring" size="30" value="{$smarty.get.substring}"> </td> </tr> {* ======email search========= *} <tr> <td height="10" class=FormButton nowrap>{$lng.lbl_email}</td> <td width="10" height="10"></td> <td height="10"> <input type="text" name="email" size="30" value="{$smarty.get.email}"> </td> </tr> {* ========Zip code search=========== *} <tr> <td height="10" class=FormButton nowrap>{$lng.lbl_zip_code}</td> <td width="10" height="10"></td> <td height="10"> <input type="text" name="zipcode" size="6" value="{$smarty.get.zipcode}"> </td> </tr> {/if} {if $usertype eq "A"} <tr> <td height="10" class=FormButton nowrap>{$lng.lbl_provider}</td> <td width="10" height="10"></td> <td height="10"> <input type="text" name="provider" size="30" value="{$smarty.get.provider}"> </td> </tr> {/if}s

Paste the following into: /{your-x-cart-dir}/include/orders.php
Code:
# $Id: orders.php,v 1.20.2.2 2003/02/19 10:41:07 svowl Exp $ # # # Generate timestamp for first day of current month # $ctime = time() + $config["General"]["timezone_offset"]; $start_date = mktime (0,0,0,date("m",$ctime),1,date("Y",$ctime)); $end_date = $ctime; $objects_per_page = $config["General"]["orders_per_page_admin"]; $tmp=strstr($QUERY_STRING, "XCARTSESSID="); if (!empty($tmp)) $QUERY_STRING=ereg_replace("XCARTSESSID=([0-9a-zA-Z]*)", "", $QUERY_STRING); if($QUERY_STRING) { # # Set % as reserved name for list mode of search script # Substring condition # $substring_condition = ($substring==""?"":" and $sql_tbl[orders].login LIKE '%$substring%'"); $status_condition = ($status?" and $sql_tbl[orders].status='$status'":""); $orderid_condition = ($orderid?" and $sql_tbl[orders].orderid='$orderid'":""); $email_condition = ($email?" and $sql_tbl[orders].email LIKE '%$email%'":""); $zipcode_condition = ($zipcode?" and $sql_tbl[orders].b_zipcode='$b_zipcode'":""); # # Generate timestamps and assign then to smarty # if($StartMonth) { $start_date=mktime(0,0,0,$StartMonth,$StartDay,$StartYear); $end_date=mktime(23,59,59,$EndMonth,$EndDay,$EndYear); } $o_date = "$sql_tbl[orders].date+'".$config["General"]["timezone_offset"]."'"; $orders = func_query("select $sql_tbl[orders].*, $sql_tbl[order_details].provider from $sql_tbl[orders], $sql_tbl[order_details] where $sql_tbl[orders].orderid=$sql_tbl[order_details].orderid ".($provider?" and $sql_tbl[order_details].provider='$provider'":"")." and $o_date>=$start_date and $o_date<=$end_date".$substring_condition.$status_condition.$orderid_condition.$email_condition.$zipcode_condition." order by $sql_tbl[orders].date desc"); if(!$provider) $orders = array_merge($orders, func_query("select $sql_tbl[orders].*, $sql_tbl[giftcerts].gcid, $sql_tbl[giftcerts].purchaser, $sql_tbl[giftcerts].recipient, $sql_tbl[giftcerts].message, $sql_tbl[giftcerts].amount, $sql_tbl[giftcerts].debit, $sql_tbl[giftcerts].add_date, $sql_tbl[giftcerts].status as gc_status FROM $sql_tbl[orders], $sql_tbl[giftcerts] where $sql_tbl[orders].orderid=$sql_tbl[giftcerts].orderid and $o_date>=$start_date and $o_date<=$end_date ".$substring_condition.$status_condition.$orderid_condition.$email_condition.$zipcode_condition." order by $sql_tbl[orders].date desc")); # # Do array multisort by orderid # $orderids = array(); if(!empty($orders)) { foreach($orders as $order) $orderids[]=$order["orderid"]; array_multisort($orderids, SORT_DESC, $orders); } # # This routine removes duplications from $orders array # $orders_string = array(); if(!empty($orders)) foreach($orders as $key=>$uniq_order) if ($uniq_order["orderid"] != $orders[$key+1]["orderid"]) { $new_orders[]=$uniq_order; $orders_string [] = $uniq_order["orderid"]; } $orders=$new_orders; if ($mode != 'export') { # # If orders do not exports, separate them on the pages # $total_nav_pages = ceil(count($orders)/$objects_per_page)+1; include "../include/navigation.php"; if (is_array($orders)) $orders = array_slice($orders, $first_page, $objects_per_page); } if ($orders) foreach($orders as $k=>$v) { $orders[$k]["date"] += $config["General"]["timezone_offset"]; if ($v["add_date"]) $orders[$k]["add_date"] += $config["General"]["timezone_offset"]; } foreach($HTTP_GET_VARS as $k=>$v) { if (!empty($v) && $k != "mode") $ret_str .= "&$k=$v"; } $ret_str = ereg_replace("^&","",$ret_str); $smarty->assign("navigation_script","orders.php?$ret_str"); # # Make orders_full array, that contains detailed information about orders # $orders_full = array (); if ($orders) { foreach ($orders as $key=>$value) { $products_result = func_query ("SELECT * FROM $sql_tbl[order_details] WHERE orderid='$value[orderid]'"); if ($products_result) { foreach ($products_result as $subkey=>$subvalue) { $result = array_merge ($value, $subvalue); $product_result = func_query_first ("SELECT * FROM $sql_tbl[products] WHERE productid='$subvalue[productid]'"); if ($product_result) $result = array_merge ($result, $product_result); $orders_full [] = $result; } } $gifts_result = func_query_first ("SELECT * FROM $sql_tbl[giftcerts] WHERE orderid='$value[orderid]'"); if ($gifts_result) { $result = array_merge ($value, $gifts_result); $orders_full [] = $result; } } } if ($orders_string) $smarty->assign ("orders_string", urlencode(implode (",", $orders_string))); $smarty->assign("orders",$orders); $smarty->assign("items_count",count($orders)); } $smarty->assign("orders_full", $orders_full); $smarty->assign("start_date",$start_date); $smarty->assign("end_date",$end_date); $smarty->assign("main","orders"); ?>

Take care everyone, improvement suggestions are very welcome.

Good day.
__________________
Best Regards!
Alan
Search is my friend
Reply With Quote
  #2  
Old 04-23-2003, 03:30 AM
 
funkydunk funkydunk is offline
 

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

Default

nice
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 06-16-2003, 02:16 AM
 
successful successful is offline
 

eXpert
  
Join Date: Sep 2002
Location: Brooklyn
Posts: 208
 

Default

Very odd......email search works 100% but zip code search doesn't work at all ?
__________________
Visit us at http://www.Successfulhosting.com
We\'ll make your web site a success!

Register your own domain name for only $14.99 at http://DiscountDomainRegistry.com
Reply With Quote
  #4  
Old 07-24-2003, 07:20 PM
 
wallachee wallachee is offline
 

Senior Member
  
Join Date: Feb 2003
Posts: 102
 

Default

Doesn't work at all under 3.3.5...just leaves a blank page.
Reply With Quote
  #5  
Old 06-15-2005, 12:34 AM
  bullfrog's Avatar 
bullfrog bullfrog is offline
 

eXpert
  
Join Date: Oct 2004
Location: Oregon, USA
Posts: 366
 

Default Just a reset button?

The postings above are not for 4.x, which has most of the above functions built-in. Missing in 4.x is a form reset button. I don't yet know enough about how to make a reset (only) button. I've been looking of 'forms' tutorials, but nothing I've tried has worked.

If you've done this on 4.x, please share your technique.

Thanks!
__________________
Bullfrog ~~~ X-Cart Gold v4.7.2 (2) v4.7.8. ⌠If the road is easy, you're likely going the wrong way.■ ― Terry Goodkind
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:41 AM.

   

 
X-Cart forums © 2001-2020