eberswine Posted June 18, 2011 Share Posted June 18, 2011 I had a quick question. Is there an easy way to change the values coming into the database for the Billing State / Shipping State ? Right now the value is for example : "Colorado" Is there a way to make it be the zone_code instead? Like : "CO" instead of "Colorado" ?? Thanks so much!! Link to comment Share on other sites More sharing options...
germ Posted June 18, 2011 Share Posted June 18, 2011 I just happend to have a list of states and their abbreviations from work I did on another site, so I thought, "What the heck...". :) /admin/includes/functions/general.php ADD this code before the closing PHP tag: function tep_state_abbreviate( $state ) { switch ( strtoupper( $state ) ) { case 'ALABAMA': return 'AL'; case 'ALASKA': return 'AK'; case 'ARIZONA': return 'AZ'; case 'ARKANSAS': return 'AR'; case 'CALIFORNIA': return 'CA'; case 'COLORADO': return 'CO'; case 'CONNECTICUT': return 'CT'; case 'DELAWARE': return 'DE'; case 'DISTRICT OF COLUMBIA': return 'DC'; case 'FLORIDA': return 'FL'; case 'GEORGIA': return 'GA'; case 'HAWAII': return 'HI'; case 'IDAHO': return 'ID'; case 'ILLINOIS': return 'IL'; case 'INDIANA': return 'IN'; case 'IOWA': return 'IA'; case 'KANSAS': return 'KS'; case 'KENTUCKY': return 'KY'; case 'LOUISIANA': return 'LA'; case 'MAINE': return 'ME'; case 'MARYLAND': return 'MD'; case 'MASSACHUSETTS': return 'MA'; case 'MICHIGAN': return 'MI'; case 'MINNESOTA': return 'MN'; case 'MISSISSIPPI': return 'MS'; case 'MISSOURI': return 'MO'; case 'MONTANA': return 'MT'; case 'NEBRASKA': return 'NE'; case 'NEVADA': return 'NV'; case 'NEW HAMPSHIRE': return 'NH'; case 'NEW JERSEY': return 'NJ'; case 'NEW MEXICO': return 'NM'; case 'NEW YORK': return 'NY'; case 'NORTH CAROLINA': return 'NC'; case 'NORTH DAKOTA': return 'ND'; case 'OHIO': return 'OH'; case 'OKLAHOMA': return 'OK'; case 'OREGON': return 'OR'; case 'PENNSYLVANIA': return 'PA'; case 'RHODE ISLAND': return 'RI'; case 'SOUTH CAROLINA': return 'SC'; case 'SOUTH DAKOTA': return 'SD'; case 'TENNESSEE': return 'TN'; case 'TEXAS': return 'TX'; case 'UTAH': return 'UT'; case 'VERMONT': return 'VT'; case 'VIRGINIA': return 'VA'; case 'WASHINGTON': return 'WA'; case 'WEST VIRGINIA': return 'WV'; case 'WISCONSIN': return 'WI'; case 'WYOMING': return 'WY'; } } Same file /admin/includes/functions/general.php Find the function: function tep_address_format($address_format_id, $address, $html, $boln, $eoln) { In that function find this line: $state = tep_output_string_protected($address['state']); Change to this: // $state = tep_output_string_protected($address['state']); $state = tep_output_string_protected( tep_state_abbreviate( $address['state'] ) ); I tested the code and it worked for me. It is always an excellent idea to backup a file before making edits to it. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
germ Posted June 18, 2011 Share Posted June 18, 2011 I should mention this change will affect all places the address is displayed in the admin. If you only want to change how it displays on the "Orders" page we'd need to approach the problem from a slightly different angle. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
eberswine Posted June 18, 2011 Author Share Posted June 18, 2011 I should mention this change will affect all places the address is displayed in the admin. If you only want to change how it displays on the "Orders" page we'd need to approach the problem from a slightly different angle. Wow, you are amazing!! Great. I basically only have one problem that I need this on... In the admin, I have export orders CSV function -- We use this for US Mail purposes and they need everything in the CSV to be "Abbreviation" when it comes to States, .. so right now it has States as "Colorado".. I think we can use your function to run it through first and then output it to CSV ? Could I ask for one more piece of help, please?? Here is the CSV export function : Basically, the only variable we need to worry about is, $csv_output .= "Billing_State".$delim; $csv_output .= "ShipTo_State".$delim; $csv_output .= $ShipTo_State . "," ; $csv_output .= $Billing_State . "," ; I think we would just need to run these through your function first, right?? <?php /* $Id: exportorders.php,v 1.1 April 21, 2006 Harris Ahmed $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2004 Oscommerce Use this module on your own risk. I will be updating a new one soon. This template is used to create the csv export for Ideal Computer Systems Accounting Software */ define('FILENAME_EXPORTORDERS', 'exportorders.php'); require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_EXPORTORDERS); // Check if the form is submitted if (!$_GET['submitted']) { ?> <!-- header_eof //--> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"></td> </tr> </table></td> </tr> <!-- first ends // --> <tr> <td><table border="0" style="font-family:tahoma;font-size:11px;" width="100%" cellspacing="2" cellpadding="2"> <tr> <td><form method="GET" action="<?php echo $PHP_SELF; ?>"> <table border="0" style="font-family:tahoma;font-size:11px;" cellpadding="3"> <tr> <td><?php echo INPUT_START; ?></td> <td><!-- input name="start" size="5" value="<?php echo $start; ?>"> --> <?php $orders_list_query = tep_db_query("SELECT orders_id, date_purchased FROM orders ORDER BY orders_id"); $orders_list_array = array(); $orders_list_array[] = array('id' => '', 'text' => '---'); while ($orders_list = tep_db_fetch_array($orders_list_query)) { $orders_list_array[] = array('id' => $orders_list['orders_id'], 'text' => $orders_list['orders_id']." - ".tep_date_short($orders_list['date_purchased'])); } echo ' ' . tep_draw_pull_down_menu('start', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . ' '; ?></td> </tr> <tr> <td><?php echo INPUT_END; ?></td> <td><!-- <input name="end" size="5" value="<?php echo $end; ?>"> --> <?php echo ' ' . tep_draw_pull_down_menu('end', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . ' '; ?></td> </tr> <tr> <td> </td> <td><input type="submit" value="<?php echo INPUT_VALID; ?>"></td> </tr> </table> <input type="hidden" name="submitted" value="1"> </form></td> </tr> <tr> <td><?php echo INPUT_DESC; ?></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table></td> </tr> </table></td> </tr> </table> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> <?php } // submitted so generate csv if the form is submitted else { generatecsv($_GET['start'], $_GET['end']); } // generates csv file from $start order to $end order, inclusive function generatecsv($start, $end) { //Placing columns names in first row $delim = ',' ; $csv_output .= "Orders_id".$delim; $csv_output .= "Date".$delim; $csv_output .= "Time".$delim; $csv_output .= "F_name".$delim; $csv_output .= "L_name".$delim; $csv_output .= "Name_On_Card".$delim; $csv_output .= "Company".$delim; $csv_output .= "email".$delim; $csv_output .= "Billing_Address_1".$delim; $csv_output .= "Billing_Address_2".$delim; $csv_output .= "Billing_City".$delim; $csv_output .= "Billing_State".$delim; $csv_output .= "Billing_Zip".$delim; $csv_output .= "Billing_Country".$delim; $csv_output .= "Billing_Phone".$delim; $csv_output .= "ShipTo_First_Name".$delim; $csv_output .= "ShipTo_Last_Name".$delim; $csv_output .= "ShipTo_Name".$delim; $csv_output .= "ShipTo_Company".$delim; $csv_output .= "ShipTo_Address_1".$delim; $csv_output .= "ShipTo_Address_2".$delim; $csv_output .= "ShipTo_City".$delim; $csv_output .= "ShipTo_State".$delim; $csv_output .= "ShipTo_Zip".$delim; $csv_output .= "ShipTo_Country".$delim; $csv_output .= "ShipTo_Phone".$delim; //$csv_output .= "Card_Type".$delim; //$csv_output .= "Card_Number".$delim; //$csv_output .= "Exp_Date".$delim; //$csv_output .= "Bank_Name".$delim; //$csv_output .= "Gateway".$delim; //$csv_output .= "AVS_Code".$delim; $csv_output .= "Transaction_ID".$delim; $csv_output .= "Order_Special_Notes".$delim; $csv_output .= "Comments".$delim; $csv_output .= "Order_Subtotal".$delim; $csv_output .= "Order_Tax".$delim; $csv_output .= "Order_Insurance".$delim; $csv_output .= "Tax_Exempt_Message".$delim; $csv_output .= "Order_Shipping_Total".$delim; //$csv_output .= "Small_Order_Fee".$delim; //$csv_output .= "Discount_Rate".$delim; //$csv_output .= "Discount_Message".$delim; //$csv_output .= "CODAmount".$delim; $csv_output .= "Order_Grand_Total".$delim; $csv_output .= "Number_of_Items".$delim; $csv_output .= "Shipping_Method".$delim; $csv_output .= "Shipping_Weight".$delim; //$csv_output .= "Coupon_Code".$delim; //$csv_output .= "Order_security_msg.".$delim; //$csv_output .= "Order_Surcharge_Amount".$delim; //$csv_output .= "Order_Surcharge_Something".$delim; //$csv_output .= "Affiliate_code".$delim; //$csv_output .= "Sentiment_message".$delim; //$csv_output .= "Checkout_form_type".$delim; //$csv_output .= "Card_CVV_value".$delim; //$csv_output .= "future1".$delim; //$csv_output .= "future2".$delim; //$csv_output .= "future3".$delim; //$csv_output .= "future4".$delim; //$csv_output .= "future5".$delim; //$csv_output .= "future6".$delim; //$csv_output .= "future7".$delim; //$csv_output .= "future8".$delim; //$csv_output .= "future9".$delim; $csv_output .= "Remarks".$delim; $csv_output .= "ProductId".$delim; $csv_output .= "Product_Price".$delim; $csv_output .= "Number".$delim; $csv_output .= "Product".$delim; $csv_output .= "Attribute".$delim; $csv_output .= "Attribute_Value".$delim; $csv_output .= "\n"; //End Placing columns in first row // Patch dlan // if both fields are empty we select all orders if ($start=="" && $end=="") { $orders = tep_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires FROM orders ORDER BY orders_id"); // if $start is empty we select all orders up to $end } else if($start=="" && $end!="") { $orders = tep_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires FROM orders WHERE orders_id <= $end ORDER BY orders_id"); // if $end is empty we select all orders from $start } else if($start!="" && $end=="") { $orders = tep_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires FROM orders WHERE orders_id >= $start ORDER BY orders_id"); // if both fields are filed in we select orders betwenn $start and $end } else { $orders = tep_db_query("SELECT orders.orders_id, orders.date_purchased, orders.customers_name, orders.cc_owner, orders.customers_company, orders.customers_email_address, orders.billing_street_address, orders.billing_city, orders.billing_state, orders.billing_postcode, orders.billing_country, orders.customers_telephone, orders.delivery_name, orders.delivery_company, orders.delivery_street_address, orders.delivery_city, orders.delivery_state, orders.delivery_postcode, orders.delivery_country, orders.cc_type, orders.cc_number, orders.cc_expires, customers.customers_id, customers.customers_firstname, customers.customers_lastname FROM orders,customers WHERE customers.customers_id = orders.customers_id AND orders.orders_id >= $start AND orders.orders_id <= $end ORDER BY orders.orders_id"); } //patch //$csv_output ="\n"; while ($row_orders = mysql_fetch_array($orders)) { //start one loop $csv_output_ordersbefore = $csv_output; $Orders_id = $row_orders["orders_id"]; $Date1 = $row_orders["date_purchased"]; //list($Date, $Time) = explode (' ',$Date1); $Date = date('m/d/Y', strtotime($Date1)); $Time= date('H:i:s', strtotime($Date1)); $Name_On_Card1 = $row_orders["customers_name"]; $Name_On_Card = filter_text($Name_On_Card1);// order changed //list($First_Name,$Last_Name) = explode(', ',$Name_On_Card1); // order changed $F_name = $row_orders["customers_firstname"]; $L_name = $row_orders["customers_lastname"]; $Company = filter_text($row_orders["customers_company"]); $email = filter_text($row_orders["customers_email_address"]); $Billing_Address_1 = filter_text($row_orders["billing_street_address"]); $Billing_Address_2 = ""; $Billing_City = filter_text($row_orders["billing_city"]); $Billing_State = filter_text($row_orders["billing_state"]); $Billing_Zip = filter_text($row_orders["billing_postcode"]); $Billing_Country = str_replace("(48 Contiguous Sta", "", $row_orders["billing_country"]); $Billing_Phone = filter_text($row_orders["customers_telephone"]); $ShipTo_Name1 = $row_orders["delivery_name"]; $ShipTo_Name = filter_text($ShipTo_Name1); // order changed list($ShipTo_First_Name,$ShipTo_Last_Name) = explode(', ',$ShipTo_Name1); // order changed $ShipTo_Company = filter_text($row_orders["delivery_company"]); $ShipTo_Address_1 = filter_text($row_orders["delivery_street_address"]); $ShipTo_Address_2 = ""; $ShipTo_City = filter_text($row_orders["delivery_city"]); $ShipTo_State = filter_text($row_orders["delivery_state"]); $ShipTo_Zip = filter_text($row_orders["delivery_postcode"]); $ShipTo_Country = str_replace("(48 Contiguous Sta", "", $row_orders["delivery_country"]); $ShipTo_Phone = ""; $Card_Type = $row_orders["cc_type"]; $Card_Number = $row_orders["cc_number"]; $Exp_Date = $row_orders["cc_expires"]; $Bank_Name = ""; $Gateway = ""; $AVS_Code = ""; $Transaction_ID = ""; $Order_Special_Notes = ""; // -------------------- QUERIES 1 ------------------------------------// //Orders_status_history for comments $orders_status_history = tep_db_query("select comments from orders_status_history where orders_id = " . $Orders_id); //$row_orders_status_history = tep_db_fetch_array($comments); while($row_orders_status_history = mysql_fetch_array($orders_status_history)) { // end // $Comments = filter_text($row_orders_status_history["comments"]); } // -------------------- QUERIES 2 ------------------------------------// //Orders_subtotal $orders_subtotal = tep_db_query("select value from orders_total where class = 'ot_subtotal' and orders_id = " . $Orders_id); //$row_orders_subtotal = tep_db_fetch_array($orders_subtotal); while($row_orders_subtotal = mysql_fetch_array($orders_subtotal)) { // end // $Order_Subtotal = filter_text($row_orders_subtotal["value"]); } // -------------------- QUERIES 3 ------------------------------------// //Orders_tax $orders_tax = tep_db_query("select value from orders_total where class = 'ot_tax' and orders_id = " . $Orders_id); //$row_orders_tax = tep_db_fetch_array($orders_tax); while($row_orders_tax = mysql_fetch_array($orders_tax)) { // end // $Order_Tax = filter_text($row_orders_tax["value"]); } // -------------------- QUERIES 4 ------------------------------------// //Orders_Insurance $orders_insurance = tep_db_query("select value from orders_total where class = 'ot_insurance' and orders_id = " . $Orders_id); //$row_orders_insurance = tep_db_fetch_array($orders_insurance); while($row_orders_insurance = mysql_fetch_array($orders_insurance)) { // end // $Order_Insurance = filter_text($row_orders_insurance["value"]); } $Tax_Exempt_Message = ""; // -------------------- QUERIES 5 ------------------------------------// //Orders_Shipping $orders_shipping = tep_db_query("select title, value from orders_total where class = 'ot_shipping' and orders_id = " . $Orders_id); //$row_orders_shipping = tep_db_fetch_array($orders_shipping); while($row_orders_shipping = mysql_fetch_array($orders_shipping)) { // end // $Order_Shipping_Total = $row_orders_shipping["value"]; $Shipping_Method = filter_text($row_orders_shipping["title"]); // Shipping method from query 5 } // -------------------- QUERIES 6 ------------------------------------// //Orders_Residential Del Fee (Giftwrap) $orders_residential_fee = tep_db_query("select value from orders_total where class = 'ot_giftwrap' and orders_id = " . $Orders_id); //$row_orders_residential_fee = tep_db_fetch_array($orders_residential_fee); while($row_orders_residential_fee = mysql_fetch_array($orders_residential_fee)) { // end // $Small_Order_Fee = $row_orders_residential_fee["value"]; } //////////////////////////////////// $Discount_Rate = ""; $Discount_Message = ""; $CODAmount = ""; // -------------------- QUERIES 7 ------------------------------------// //Orders_Total $orders_total = tep_db_query("select value from orders_total where class = 'ot_total' and orders_id = " . $Orders_id); //$row_orders_total = tep_db_fetch_array($orders_total); while($row_orders_total = mysql_fetch_array($orders_total)) { // end // $Order_Grand_Total = $row_orders_total["value"]; } // -------------------- QUERIES 8 ------------------------------------// //Products COunt $orders_count = tep_db_query("select count(products_quantity) as o_count from orders_products where orders_id = " . $Orders_id); //$row_orders_total = tep_db_fetch_array($orders_total); while($row_orders_count = mysql_fetch_array($orders_count)) { // end // $Number_of_Items = $row_orders_count[0]; // used array to show the number of items ordered } // $Shipping_Weight = ""; $Coupon_Code = ""; $Order_security_msg = ""; $Order_Surcharge_Amount = ""; $Order_Surcharge_Something = ""; $Affiliate_code = ""; $Sentiment_message = ""; $Checkout_form_type = ""; $Card_CVV_value = $row_orders["cvvnumber"]; $future1 = ""; $future2 = ""; $future3 = ""; $future4 = ""; $future5 = ""; $future6 = ""; $future7 = ""; $future8 = ""; $future9 = ""; // csv settings $CSV_SEPARATOR = ","; $CSV_NEWLINE = "\r\n"; $csv_output .= $Orders_id . "," ; $csv_output .= $Date . "," ; $csv_output .= $Time . "," ; $csv_output .= $F_name . "," ; $csv_output .= $L_name . "," ; $csv_output .= $Name_On_Card . "," ; $csv_output .= $Company . "," ; $csv_output .= $email . "," ; $csv_output .= $Billing_Address_1 . "," ; $csv_output .= $Billing_Address_2 . "," ; $csv_output .= $Billing_City . "," ; $csv_output .= $Billing_State . "," ; $csv_output .= $Billing_Zip . "," ; $csv_output .= $Billing_Country . "," ; $csv_output .= $Billing_Phone . "," ; $csv_output .= $ShipTo_First_Name . "," ; $csv_output .= $ShipTo_Last_Name . "," ; $csv_output .= $ShipTo_Name . "," ; $csv_output .= $ShipTo_Company . "," ; $csv_output .= $ShipTo_Address_1 . "," ; $csv_output .= $ShipTo_Address_2 . "," ; $csv_output .= $ShipTo_City . "," ; $csv_output .= $ShipTo_State . "," ; $csv_output .= $ShipTo_Zip . "," ; $csv_output .= $ShipTo_Country . "," ; $csv_output .= $ShipTo_Phone . "," ; //$csv_output .= $Card_Type . "," ; //$csv_output .= $Card_Number . "," ; //$csv_output .= $Exp_Date . "," ; //$csv_output .= $Bank_Name . "," ; //$csv_output .= $Gateway . "," ; //$csv_output .= $AVS_Code . "," ; $csv_output .= $Transaction_ID . "," ; $csv_output .= $Order_Special_Notes . "," ; $csv_output .= $Comments . "," ; $csv_output .= $Order_Subtotal . "," ; $csv_output .= $Order_Tax . "," ; $csv_output .= $Order_Insurance . "," ; $csv_output .= $Tax_Exempt_Message . "," ; $csv_output .= $Order_Shipping_Total . "," ; //$csv_output .= $Small_Order_Fee . "," ; //$csv_output .= $Discount_Rate . "," ; //$csv_output .= $Discount_Message . "," ; //$csv_output .= $CODAmount . "," ; $csv_output .= $Order_Grand_Total . "," ; $csv_output .= $Number_of_Items . "," ; $csv_output .= $Shipping_Method . "," ; $csv_output .= $Shipping_Weight . "," ; //$csv_output .= $Coupon_Code . "," ; //$csv_output .= $Order_security_msg . "," ; //$csv_output .= $Order_Surcharge_Amount . "," ; //$csv_output .= $Order_Surcharge_Something . "," ; //$csv_output .= $Affiliate_code . "," ; //$csv_output .= $Sentiment_message . "," ; //$csv_output .= $Checkout_form_type . "," ; //$csv_output .= $Card_CVV_value . "," ; //$csv_output .= $future1 . "," ; //$csv_output .= $future2 . "," ; //$csv_output .= $future3 . "," ; //$csv_output .= $future4 . "," ; //$csv_output .= $future5 . "," ; //$csv_output .= $future6 . "," ; //$csv_output .= $future7 . "," ; //$csv_output .= $future8 . "," ; //$csv_output .= $future9 ; // -------------------- QUERIES 9 ------------------------------------// //Get list of products ordered $orders_products = tep_db_query("select products_model, products_price, products_quantity, products_name, orders_products_id from orders_products where orders_id = " . $Orders_id); // While loop to list the item $countproducts = 0; $csv_output_item = ""; $csv_output_order = str_replace($csv_output_ordersbefore, "", $csv_output); while($row_orders_products = mysql_fetch_array($orders_products)) { // loop through orders // More than one product per order, new line if ($countproducts>0){ $csv_output .= "\n"; $csv_output .= $csv_output_order; $csv_output_item = ""; } // $csv_output_item .= "," . "BEGIN_ITEM". "," ; $csv_output_item .= ","; $csv_output_item .= filter_text($row_orders_products[0]) . "," ; $csv_output_item .= $row_orders_products[1] . "," ; $csv_output_item .= $row_orders_products[2] . "," ; $csv_output_item .= filter_text($row_orders_products[3]) . "," ; $Products_id = $row_orders_products[4]; $orders_products_attributes = tep_db_query("select products_options, products_options_values from orders_products_attributes where orders_id = " . $Orders_id . " and orders_products_id = " . $Products_id); while($row_orders_products_attributes = mysql_fetch_array($orders_products_attributes)) { $csv_output_item .= filter_text($row_orders_products_attributes[0]) . "," ; $csv_output_item .= filter_text($row_orders_products_attributes[1]) . "," ; } // $csv_output_item .= "END_ITEM"; $csv_output .= $csv_output_item; $countproducts += 1; } // end while loop for products // --------------------------------------------------------------------------// $csv_output .= "\n"; } // while loop main first //print header("Content-Type: application/force-download\n"); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Content-Disposition: attachment; filename=ordersexports_" . date("Ymd") . ".csv"); print $csv_output; exit; }//function main function filter_text($text) { $filter_array = array(",","\r","\n","\t"); return str_replace($filter_array,"",$text); } // function for the filter ?> Link to comment Share on other sites More sharing options...
germ Posted June 18, 2011 Share Posted June 18, 2011 Actually I'm Scottish, but that's a whole different story... :blink: The answer to your question is "Yes" and "No". Backup the file. Change this line: $Billing_State = filter_text($row_orders["billing_state"]); To: $Billing_State = filter_text( tep_state_abbreviate( $row_orders["billing_state"] ) ); Change this line: $ShipTo_State = filter_text($row_orders["delivery_state"]); To: $ShipTo_State = filter_text( tep_state_abbreviate( $row_orders["delivery_state"] ) ); Test it to be sure you get what you want. :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
germ Posted June 18, 2011 Share Posted June 18, 2011 A small code improvement. Change the last two lines in the function tep_state_abbreviate : } } To: } return $state; } If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
eberswine Posted June 18, 2011 Author Share Posted June 18, 2011 Oh my GOD!! You are a NINJA!!! Wow, thanks so much!! That worked amazing!! Link to comment Share on other sites More sharing options...
germ Posted June 18, 2011 Share Posted June 18, 2011 You're welcome. :) Yep.... That's me..... a Scottish Ninja.... :lol: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
burt Posted June 19, 2011 Share Posted June 19, 2011 tep_get_zone_code() :rolleyes: Link to comment Share on other sites More sharing options...
germ Posted June 30, 2011 Share Posted June 30, 2011 The best part of this is it's minimally intrusive to the core code of osC. Change one line of core code, add one function, and it adds the state abbreviation in orders, invoice, and packing slip files with no changes to the files themselves. Got better code? :unsure: Put your money where your mouth is and post it. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
burt Posted June 30, 2011 Share Posted June 30, 2011 // Function : tep_get_zone_code // // Arguments : country country code string // zone state/province zone_id // def_state default string if zone==0 // // Return : state_prov_code state/province code // // Description : Function to retrieve the state/province code (as in FL for Florida etc) Put up or shut up. I've put up, now how about you shut up & stop this childishness when someone posts code that should have been posted in the first place if you knew just a little more PHP than you do. Your solutions work, but why not listen to other solutions which are already there to use. Link to comment Share on other sites More sharing options...
germ Posted June 30, 2011 Share Posted June 30, 2011 Shutup? :unsure: Not in the bloody pit of Hades. Just another of your typical answers - long on talk and short on original code or tangible help. If you knew half as much as you think you do you'd be twice the help you currently are. You haven't put up anything besides your usual rhetoric. "listen to other solutions"... Hmmmm.... Let's have a look here.... Gee... No one has posted any "other solutions". All I see are useless code snippets. Childishness? :unsure: No, that's what you have when someone tries to find fault in someone else's work but they fail to produce anything better of their own. :huh: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
burt Posted July 1, 2011 Share Posted July 1, 2011 Ho hum. Quite how one sentence can be "long on talk" is beyond me. tep_get_zone_code is a native function in osCommerce, so it's hardly a "useless code snippet". It does precisely what your code does, but it does it properly by taking data that is already available and using it. If you knew about it you would surely have used it. What I have done is point out where your code should be improved - you took it upon yourself to personally abuse me in one of your readme's. Then you took it upon yourself to personally abuse me in your posts and status updates == childishness. I've never abused you personally, which is more than can be said for you (and a few others on this forum). If you need me to explain step by step how to use tep_get_zone_code I will do. Link to comment Share on other sites More sharing options...
ari73 Posted July 1, 2011 Share Posted July 1, 2011 Shutup? :unsure: Not in the bloody pit of Hades. Just another of your typical answers - long on talk and short on original code or tangible help. If you knew half as much as you think you do you'd be twice the help you currently are. You haven't put up anything besides your usual rhetoric. "listen to other solutions"... Hmmmm.... Let's have a look here.... Gee... No one has posted any "other solutions". All I see are useless code snippets. Childishness? :unsure: No, that's what you have when someone tries to find fault in someone else's work but they fail to produce anything better of their own. :huh: I'm only new to this forum and I would like to say germ was great community helper....! He took the time out of his own personnel time to code it up for me - it may of been a simple task but it got me out of trouble. but whats more importantly he actually helped instead of pointing out my faults or ignoring my post to help..... Germ keep up the good work and I'm pretty sure the people you have helped are very gratefull like me.... P.S burt if you were only pointing out that it could be done better then you should of taken the time to post code snippet of how it should have been done for all community forum members to learn and use as a reference. not here to play forum wars or take sides but trying to get more constructive posts by posting code snippets examples Ari Link to comment Share on other sites More sharing options...
burt Posted July 1, 2011 Share Posted July 1, 2011 Ari, you are right - I apologise. I'll try harder next time to also post the actual code rather than assume that giving the existing function would be enough. Link to comment Share on other sites More sharing options...
germ Posted July 2, 2011 Share Posted July 2, 2011 Oh gee... Here we go... Playing the "I'm just poor little abused burt" card.... :'( ***sniff*** ***sniff*** Everyone be sure to send him a clean hanky. Ho hum. Quite how one sentence can be "long on talk" is beyond me. Many things fall into that category. tep_get_zone_code is a native function in osCommerce, so it's hardly a "useless code snippet". If all you do is copy/paste it into a post it's still just that - a useless code snippet, any way you slice it. What I have done is point out where your code should be improved - you took it upon yourself to personally abuse me in one of your readme's. Then you took it upon yourself to personally abuse me in your posts and status updates == childishness. I've never abused you personally, which is more than can be said for you (and a few others on this forum). You aren't mentioned in any of the readme's I've made. What alternate reality do you reside in? You have "abuse" confused with that "If the shoe fits - wear it" feeling in the pit of your stomach you got while reading it. So let me set the record straight for all the world to see. I did mention the words '"self proclained" code critic' in a readme file but not a single name or nickname is mentioned with it - ANYWHERE! If anyone has it in their signature I can only assume they do so as an admittance to get it off their conscience. If you think for a nanosecond I'm going to sit idle while you post half truths you've made a grievous error in judgement. And don't bring up the status updates. You started that - not me. If you can't take the heat stay away from the fire. If you need me to explain step by step how to use tep_get_zone_code I will do. If you feel the need to explain anything how about your version of a solution to the OP's problem for starters? :unsure: Just like mine - change only one line in the core code and make only one new function and the abbreviated state will show on the order, invoice, and packing slip pages. If you have to do more than that you're going way too far just to use a "native function" only because "it's there". Or maybe it's just too much to ask... Four posts in this thread and counting, and still no working solution to the problem from you. Only fragments of someone elses's work. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
IWAS Posted October 26, 2011 Share Posted October 26, 2011 Germ, Thank you, I was really struggling with this as I am quite the novice and you made it crystal clear what to put where. Found code snippets of similar things, but you made it simple as a pimple I used it modifying another add-on to do a Paypal Multi-order shipping add-on (http://addons.oscommerce.com/info/8201) Again, Thank you Link to comment Share on other sites More sharing options...
germ Posted October 26, 2011 Share Posted October 26, 2011 You're welcome. As you probably noticed there's a slight difference of opinion on how to best solve the problem. I'll just leave it at that... for now. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.