Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Does each order line have a unique ID number


dvharrison

Recommended Posts

Hi all

 

I am using http://addons.oscommerce.com/info/4728 to export our order data into CSV format, however in order for it to work fully, a unique item ID is necessary for orders with more than one product.

 

My question is, is an order item ID available in the database as standard? If not, is there an add-on which can accomplish this? I have had a search but as yet I cannot find anything.

 

Furthermore, would it be simple to add a unique order item ID to the CSV output? I have a basic knowledge of PHP, and am a very quick learner.

 

I look forward to receiving any help. Please please don't ignore me.

 

Many thanks in advance

Edited by dvharrison

Debbie Harrison

 

Link to comment
Share on other sites

I have looked in the database and under orders_products, there are the fields orders_products_id and products_id. I am assuming that one is the part number (to which we've got and the other is a unique identifier to the product line number. Is that correct?

Debbie Harrison

 

Link to comment
Share on other sites

orders_id in the orders table is a unique ID. It's in most of the other orders tables as well, for the obvious reason. This should already be available in your CSV output.

 

products_id is a unique identifier for the product, and is equivalent to orders_products_id.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

products_id is a unique identifier for the product, and is equivalent to orders_products_id.

 

Thanks for your help Jim

 

So are products_id and orders_products_id one of the same thing? I am looking for a unique identifier for each line placed in an order.

Debbie Harrison

 

Link to comment
Share on other sites

Yes they are. There's a database diagram in the osCommerce distribution -- look in the extras folder. That will give you the identifier for each table and how it relates to other tables.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

After having a play, the order_products_id seems to be the unique identifier that I need.

 

Now I've just got to work out how to add each product ordered onto separate lines and I should be sorted. Newbie question: Any ideas how I do this? ;)

Debbie Harrison

 

Link to comment
Share on other sites

If I understand you correctly, take a look at catalog/admin/orders.php. The SQL there should be about what you need.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Well, I have the page that creates the delimited file and I seem to be successful thus far. <_<

 

Getting a bit technical, I need the order line loop to end if only 1 product line is ordered (otherwise the following header information carried onto a blank line. I am assuming its an if else function.

 

Relevant PHP is here:

 

}
$csv_output .= $close_header;
$csv_output .= $submitted == 1 ? $open_column.$order_num.$delim : $open_column."<a href=".$order_url.$order_num.$order_edit.">".$order_num."</a>".$delim;
$csv_output .= $open_column.$Date . $delim;
$csv_output .= $open_column.$kvorname . " " . $knachname . $delim;
$csv_output .= $open_column.$Billing_Address_1 . $delim;
$csv_output .= $open_column.$Billing_Address_2 . $delim;
$csv_output .= $open_column.$Billing_City . $delim;
$csv_output .= $open_column.$Billing_State . $delim;
$csv_output .= $open_column.$Billing_Zip . $delim;
$csv_output .= $open_column.$Billing_Phone . $delim;

$csv_output .= $open_column.$ShipTo_First_Name . " " .$ShipTo_Last_Name. $delim;
$csv_output .= $open_column.$ShipTo_Address_1 . $delim;
$csv_output .= $open_column.$ShipTo_Address_2 . $delim;
$csv_output .= $open_column.$ShipTo_City . $delim;
$csv_output .= $open_column.$ShipTo_State . $delim;
$csv_output .= $open_column.$ShipTo_Zip . $delim;
$csv_output .= $open_column.$Shipping_Method . $delim;
$csv_output .= $open_column.$Order_Shipping_Total . $delim;


$csv_output .= $open_header;
if($submitted == 2){ // Html output to screen
$csv_output .= "<td width=100>Model".$delim;
$csv_output .= "<td width=25>Qty".$delim;
$csv_output .= "<td width=250>Product".$delim;
$csv_output .= "<td width=100>Price".$delim;
}
$csv_output .= $close_header;
while($row_orders_products = mysql_fetch_array($orders_products)) {

//$csv_output .= $open_column.$order_url.$order_num.$order_edit . $delim;

$csv_output .= $open_column.filter_text($row_orders_products[0]) . $delim;
$csv_output .= $open_column.$row_orders_products[1] . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[3]) . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[2]) . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[4]) . $delim;
$csv_output .= $submitted == 1 ? "" : "";
$csv_output .= "\n";  // If else Needed on this line!!

$csv_output .= $open_column.$order_num . $delim;
$csv_output .= $open_column.$Date . $delim;
$csv_output .= $open_column.$kvorname . " " . $knachname . $delim;

} // end while loop for products
$csv_output .= $close_table;
$csv_output .= $submitted == 1 ? "" : "<br>";

 

I would soo appreciate any knowledge here. As I said I am a PHP newbie but can follow patterns and use common sense.

 

When I have completed this I shall share the page on the addon as tradeBox Finance Manager must be used by more than 1 person in the community (Surely!).

Edited by dvharrison

Debbie Harrison

 

Link to comment
Share on other sites

I guess I don't understand the problem. Are you trying to remove the newline from the last product line? If so, removing is probably the way to go, as detecting the last line isn't easy. OK, you could count the lines in advance, set up an index, and then use your if() statement to detect the last one. Not fun.

 

If that's not what you are talking about, then I'm completely lost.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

You've confused me now. The guy at Tradeboc said this:

 

Each separate product purchased needs to be on a separate line. If a buyer purchases more than one item, in the same visit, then each item purchased should have the same order ID but a separate transaction or item ID, as follows:

 

 

 

Order

Transaction

Date

Customer

SKU

Product

 

123

100

01/06/2009

James Smith

ABC123

Nokia 6210

 

123

101

01/06/2009

James Smith

XYZ789

Nokia Memory Card

 

124

102

01/06/2009

Jane Doe

ABC555

I-Phone

 

 

 

 

Not only does this allow invoices to be created it allows us to import the file. Having separate transactions on separate lines is key to importing any file into Sage.

 

I have accomplished this all bar an empty line at the bottom of each order.

 

I hope this is clearer.

 

Many thanks ;)

Debbie Harrison

 

Link to comment
Share on other sites

The newline (\n) creates a new line. Having an extra newline at the end of the order creates a blank line, since there is no output after that point. So the answer is Yes.

 

I still think that the easiest way to do this is remove the extra newline . One way is to add this to the end of your script:

$csv_output = rtrim ($csv_output);

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Ok Just so i am clear, where do I add this? Right at the end?

 

I have had a play and it appears to stuff everything on 1 line (what I need to avoid).

 

Last bit of script is this:

 

$csv_output .= $close_header;
$csv_output .= $submitted == 1 ? $open_column.$order_num.$delim : $open_column."<a href=".$order_url.$order_num.$order_edit.">".$order_num."</a>".$delim;
$csv_output .= $open_column.$Date . $delim;
$csv_output .= $open_column.$kvorname . " " . $knachname . $delim;
$csv_output .= $open_column.$Billing_Address_1 . $delim;
$csv_output .= $open_column.$Billing_Address_2 . $delim;
$csv_output .= $open_column.$Billing_City . $delim;
$csv_output .= $open_column.$Billing_State . $delim;
$csv_output .= $open_column.$Billing_Zip . $delim;
$csv_output .= $open_column.$Billing_Phone . $delim;

$csv_output .= $open_column.$ShipTo_First_Name . " " .$ShipTo_Last_Name. $delim;
$csv_output .= $open_column.$ShipTo_Address_1 . $delim;
$csv_output .= $open_column.$ShipTo_Address_2 . $delim;
$csv_output .= $open_column.$ShipTo_City . $delim;
$csv_output .= $open_column.$ShipTo_State . $delim;
$csv_output .= $open_column.$ShipTo_Zip . $delim;
$csv_output .= $open_column.$Shipping_Method . $delim;
$csv_output .= $open_column.$Order_Shipping_Total . $delim;


$csv_output .= $open_header;
if($submitted == 2){ // Html output to screen
$csv_output .= "<td width=100>Model".$delim;
$csv_output .= "<td width=25>Qty".$delim;
$csv_output .= "<td width=250>Product".$delim;
$csv_output .= "<td width=100>Price".$delim;
}
$csv_output .= $close_header;
while($row_orders_products = mysql_fetch_array($orders_products)) {

//$csv_output .= $open_column.$order_url.$order_num.$order_edit . $delim;

$csv_output .= $open_column.filter_text($row_orders_products[0]) . $delim;
$csv_output .= $open_column.$row_orders_products[1] . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[3]) . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[2]) . $delim;
$csv_output .= $open_column.filter_text($row_orders_products[4]) . $delim;
$csv_output .= $submitted == 1 ? "" : "";
$csv_output .= "\n"; 
$csv_output .= $open_column.$order_num . $delim;
$csv_output .= $open_column.$Date . $delim;
$csv_output .= $open_column.$kvorname . " " . $knachname . $delim;
$csv_output .= $open_column.$Billing_Address_1 . $delim;
$csv_output .= $open_column.$Billing_Address_2 . $delim;
$csv_output .= $open_column.$Billing_City . $delim;
$csv_output .= $open_column.$Billing_State . $delim;
$csv_output .= $open_column.$Billing_Zip . $delim;
$csv_output .= $open_column.$Billing_Phone . $delim;
$csv_output .= $open_column.$ShipTo_First_Name . " " .$ShipTo_Last_Name. $delim;
$csv_output .= $open_column.$ShipTo_Address_1 . $delim;
$csv_output .= $open_column.$ShipTo_Address_2 . $delim;
$csv_output .= $open_column.$ShipTo_City . $delim;
$csv_output .= $open_column.$ShipTo_State . $delim;
$csv_output .= $open_column.$ShipTo_Zip . $delim;
$csv_output .= $open_column.$Shipping_Method . $delim;
$csv_output .= $open_column.$Order_Shipping_Total . $delim;
} // end while loop for products
$csv_output .= $close_table;
$csv_output .= $submitted == 1 ? "" : "<br>";


// --------------------------------------------------------------------------//
$csv_output .= "\n";
} // while loop main first


//BOF OUTPUT
if($submitted == 1){
header("Content-Type: application/force-download\n");
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header("Content-Disposition: attachment; filename=orders_" . date("mdY") . ".csv");
print $csv_output;
}
elseif($submitted == 2){
$csv_output = str_replace("\n", "<br>", $csv_output);
echo "<p dir=rtl>".$csv_output."</p>";
}
exit;
//EOF OUTPUT
}//function main

function filter_text($text) {
$filter_array = array(",","\r","\n","\t");
return str_replace($filter_array,"",$text);
} // function for the filter
?>

 

Sorry to ask such dumb questions but thats just me. :)

Debbie Harrison

 

Link to comment
Share on other sites

It needs to be at the end of the entire file, not at the end of the line. You may need to change the variable if that's not where the data is store. I only had the bit you posted to go from.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

That snippet I gave you was the part right at the end of the file. The actual page is about 594 lines long. I could print it if you'd like.

 

So you're saying it needs to go before the closing ?>

 

I shall see what happens.

Edited by dvharrison

Debbie Harrison

 

Link to comment
Share on other sites

Possibly not all the way at the end. There's at least one function in there. The code I gave you needs to go just before the output. You need to find whatever issues a print() or echo() and filter just before that. Change the variable if needed.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I shall show the top part of the CSV output section as so far nothing I've tried seems to work. Brace yourself this is long :blink:

 

<?php
}
// submitted so generate csv if the form is submitted
else
{
generatecsv($start, $end, $status, $submitted);
}

// generates csv file from $start order to $end order, inclusive
function generatecsv($start, $end, $status, $submitted)
{

$order_edit = "&action=edit";
$order_url = "http://www.blueplasters.com/pad/orders.php?oID=$order_num";
$space = " ";

$open_table = $submitted == 1 ? '' : '<table width=100% border=1 cellspacing=0 cellpadding=0>';
$close_table = $submitted == 1 ? '' : '</table>';
$open_header = $submitted == 1 ? '' : '<tr bgcolor=#cccccc>';
$close_header = $submitted == 1 ? '' : '</tr>';
$open_row = $submitted == 1 ? '' : '<tr>';
$close_row = $submitted == 1 ? '' : '</tr>';
$open_column = $submitted == 1 ? '' : '<td><font face=verdana size=2>';
$delim = $submitted == 1 ? ',' : '</font></td>';

if($submitted == 1){ //  Heading CSV output file
$csv_output .= "Order ID".$delim;
$csv_output .= "Date".$delim;
$csv_output .= "Bill Name".$delim;
/* $csv_output .= "Last".$delim; */
$csv_output .= "Address1".$delim;
$csv_output .= "Address2".$delim;
$csv_output .= "City".$delim;
$csv_output .= "State".$delim;
$csv_output .= "Zip".$delim;
$csv_output .= "Phone".$delim;
$csv_output .= "Ship Name".$delim;
$csv_output .= "Address1".$delim;
$csv_output .= "Address2".$delim;
$csv_output .= "City".$delim;
$csv_output .= "State".$delim;
$csv_output .= "Zip".$delim;
$csv_output .= "Shipping Method".$delim;
$csv_output .= "Shipping Cost".$delim;
	$csv_output .= "Trans ID".$delim;
$csv_output .= "Model".$delim;
$csv_output .= "Qty".$delim; 
$csv_output .= "Price".$delim;
$csv_output .= "Product".$delim;
$csv_output .= "\n"; 
}

$orders = tep_db_query("select customers_id, 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, payment_method, orders_status
from " . TABLE_ORDERS . " where 1 " . ($start ? "and orders_id >= $start " : "") . ($end ? "and orders_id <= $end " : "") . ($status ? "and orders_status = $status " : "") . "order by customers_id");

while ($row_orders = mysql_fetch_array($orders)) { //start one loop

$Orders_id = $row_orders["orders_id"];
$orders_status = $row_orders["orders_status"];
$customers_id = $row_orders["customers_id"];
$customers_gender = $row_orders["customers_gender"];
$Date1 = $row_orders["date_purchased"];
//list($Date, $Time) = explode (' ',$Date1);
$Date = date('d/m/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
$Company = filter_text($row_orders["customers_company"]);
$email = filter_text($row_orders["customers_email_address"]);
$payment = filter_text($row_orders["payment_method"]);
$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 " . TABLE_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 " . TABLE_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
$Order_Tax = '0';
$orders_tax = tep_db_query("select value from " . TABLE_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 " . TABLE_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 5a  ------------------------------------//
//Orders_Shipping Versandkosten
$orders_shipping = tep_db_query("select title, value from " . TABLE_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 5b  ------------------------------------//
//Orders_Shipping_Nachnahme
unset($nn_gebuehr);
$orders_shipping_nn = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . "
where class = 'ot_cod_fee' and orders_id = " . $Orders_id);
//$row_orders_shipping_nn = tep_db_fetch_array($orders_shipping_nn);
while($row_orders_shipping_nn = mysql_fetch_array($orders_shipping_nn)) {
// end //
$nn_gebuehr = $row_orders_shipping_nn["value"];

}
// --------------------	QUERIES 5c  ------------------------------------//
//Orders_Shipping_Minderwert bei Auslandsaufträgen
unset($minderwert);
$orders_shipping_minderwert = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . "
where class = 'ot_loworderfee' and orders_id = " . $Orders_id);
//$row_orders_shipping_minderwert = tep_db_fetch_array($orders_shipping_minderwert);
while($row_orders_shipping_minderwert = mysql_fetch_array($orders_shipping_minderwert)) {
// end //
$minderwert = $row_orders_shipping_minderwert["value"];

}
// --------------------	QUERIES 5d  ------------------------------------//
//Orders_Coupon Rabatt bei Couponeinsatz
unset($coupon);
$orders_coupon = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . "
where class = 'ot_discount_coupon' and orders_id = " . $Orders_id);
//$row_orders_coupon = tep_db_fetch_array($orders_coupon);
while($row_orders_coupon = mysql_fetch_array($orders_coupon)) {
// end //
$coupon = $row_orders_coupon["value"];

}

// --------------------	QUERIES 6  ------------------------------------//
//Orders_Residential Del Fee (Giftwrap)
$orders_residential_fee = tep_db_query("select value from " . TABLE_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 Gesamtbetrag der Bestellung wird noch nicht gebraucht
$orders_total = tep_db_query("select value from " . TABLE_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  ------------------------------------//
//Kundendaten wie Name, Faxnummer und Refferer
$customers = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_fax from " . TABLE_CUSTOMERS . "
where customers_id = " . $customers_id);
//$row_customers = tep_db_fetch_array($customers);
while($row_customers = mysql_fetch_array($customers)) {
// end //
$fax = $row_customers["customers_fax"];
$gender = $row_customers["customers_gender"];
$kvorname = $row_customers["customers_firstname"];
$knachname = $row_customers["customers_lastname"];
}

// --------------------	QUERIES 9  ------------------------------------//
//Products COunt
$orders_count = tep_db_query("select count(products_quantity) as o_count from " . TABLE_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 = "";
$future1  = " ";
$future2 = "";
$future3 = "";
$future4 = "";
$future5 = "";
$future6 = "";
$future7 = "";
$future8 = "";
$future9 = "";
// csv settings
//$CSV_SEPARATOR = ";";
//$CSV_NEWLINE = "\r\n";
//$csv_output .= $Orders_id . $delim;
//$csv_output .= $Date . $delim;
//$csv_output .= $Time . $delim;
//$csv_output .= $customers_id . $delim;
//$csv_output .= $gender . $delim;
//$csv_output .= $kvorname . $delim;
//$csv_output .= $knachname . $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 .= $fax . $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 .= $payment . $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 .= $nn_gebuehr . $delim;
//$csv_output .= $minderwert . $delim;
//$csv_output .= $coupon . $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 .= $productname . $delim;
//$csv_output .= $products_price . $delim;
// --------------------	QUERIES 10  ------------------------------------//
//Get list of products ordered

$orders_products = tep_db_query("select orders_products_id, products_model, products_price, products_quantity, products_name from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = " . $Orders_id);
$productname = $row_customers["products_name"];
$order_num = $Orders_id;
// While loop to list the item
$csv_output .= $open_table;

$csv_output .= $open_header;
if($submitted == 2){ // Html output to screen
$csv_output .= "<td width=20>Order ID".$delim;
$csv_output .= "<td width=50>Date".$delim;
$csv_output .= "<td width=100>Bill Name".$delim;
$csv_output .= "<td width=100>Last".$delim;
$csv_output .= "<td width=100>Address1".$delim;
$csv_output .= "<td width=25>Address2".$delim;
$csv_output .= "<td width=100>City".$delim;
$csv_output .= "<td width=100>State".$delim;
$csv_output .= "<td width=25>Zip".$delim;
$csv_output .= "<td width=100>Phone".$delim;
$csv_output .= "<td width=100>Ship Name".$delim;
$csv_output .= "<td width=100>Address1".$delim;
$csv_output .= "<td width=25>Address2".$delim;
$csv_output .= "<td width=100>City".$delim;
$csv_output .= "<td width=100>State".$delim;
$csv_output .= "<td width=25>Zip".$delim;
$csv_output .= "<td width=100>Ship Method".$delim;
$csv_output .= "<td width=25>Ship Cost".$delim;
}
$csv_output .= $close_header;
$csv_output .= $submitted == 1 ? $open_column.$order_num.$delim : $open_column."<a href=".$order_url.$order_num.$order_edit.">".$order_num."</a>".$delim;
$csv_output .= $open_column.$Date . $delim;
$csv_output .= $open_column.$kvorname . " " . $knachname . $delim;
$csv_output .= $open_column.$Billing_Address_1 . $delim;
$csv_output .= $open_column.$Billing_Address_2 . $delim;
$csv_output .= $open_column.$Billing_City . $delim;
$csv_output .= $open_column.$Billing_State . $delim;
$csv_output .= $open_column.$Billing_Zip . $delim;
$csv_output .= $open_column.$Billing_Phone . $delim;

$csv_output .= $open_column.$ShipTo_First_Name . " " .$ShipTo_Last_Name. $delim;
$csv_output .= $open_column.$ShipTo_Address_1 . $delim;
$csv_output .= $open_column.$ShipTo_Address_2 . $delim;
$csv_output .= $open_column.$ShipTo_City . $delim;
$csv_output .= $open_column.$ShipTo_State . $delim;
$csv_output .= $open_column.$ShipTo_Zip . $delim;
$csv_output .= $open_column.$Shipping_Method . $delim;
$csv_output .= $open_column.$Order_Shipping_Total . $delim;


$csv_output .= $open_header;
if($submitted == 2){ // Html output to screen
$csv_output .= "<td width=100>Model".$delim;
$csv_output .= "<td width=25>Qty".$delim;
$csv_output .= "<td width=250>Product".$delim;
$csv_output .= "<td width=100>Price".$delim;
}
$csv_output .= $close_header;

					 while($row_orders_products = mysql_fetch_array($orders_products)) {

					 /* if($row_orders_products[0] != ""){ // if */
					 //$csv_output .= $open_column.$order_url.$order_num.$order_edit . $delim;

					 $csv_output .= $open_column.filter_text($row_orders_products[0]) . $delim;
					 $csv_output .= $open_column.$row_orders_products[1] . $delim;
					 $csv_output .= $open_column.filter_text($row_orders_products[3]) . $delim;
					 $csv_output .= $open_column.filter_text($row_orders_products[2]) . $delim;
					 $csv_output .= $open_column.filter_text($row_orders_products[4]) . $delim;
					 $csv_output .= $submitted == 1 ? "" : "";
					 $csv_output .= "\n";
					 $csv_output .= $open_column.$order_num . $delim;
					 $csv_output .= $open_column.$Date . $delim;
					 $csv_output .= $open_column.$kvorname . " " . $knachname . $delim;
					 $csv_output .= $open_column.$Billing_Address_1 . $delim;
					 $csv_output .= $open_column.$Billing_Address_2 . $delim;
					 $csv_output .= $open_column.$Billing_City . $delim;
					 $csv_output .= $open_column.$Billing_State . $delim;
					 $csv_output .= $open_column.$Billing_Zip . $delim;
					 $csv_output .= $open_column.$Billing_Phone . $delim;
					 $csv_output .= $open_column.$ShipTo_First_Name . " " .$ShipTo_Last_Name. $delim;
					 $csv_output .= $open_column.$ShipTo_Address_1 . $delim;
					 $csv_output .= $open_column.$ShipTo_Address_2 . $delim;
					 $csv_output .= $open_column.$ShipTo_City . $delim;
					 $csv_output .= $open_column.$ShipTo_State . $delim;
					 $csv_output .= $open_column.$ShipTo_Zip . $delim;
					 $csv_output .= $open_column.$Shipping_Method . $delim;
					 $csv_output .= $open_column.$Order_Shipping_Total . $delim;
					/* } // end if */
			} // end while loop for products


$csv_output .= $close_table;
$csv_output .= $submitted == 1 ? "" : "<br>";


// --------------------------------------------------------------------------//
$csv_output .= "\n";
} // while loop main first


//BOF OUTPUT
if($submitted == 1){
header("Content-Type: application/force-download\n");
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header("Content-Disposition: attachment; filename=orders_" . date("dmY") . ".csv");
print $csv_output;
}
elseif($submitted == 2){
$csv_output = str_replace("\n", "<br>", $csv_output);
echo "<p dir=rtl>".$csv_output."</p>";
}
exit;
//EOF OUTPUT
}//function main

function filter_text($text) {
$filter_array = array(",","\r","\n","\t");
return str_replace($filter_array,"",$text);
} // function for the filter
?>

 

Something definitely work and that line disappears. Unfrotunately it scrunches everything up on 1 line.

Debbie Harrison

 

Link to comment
Share on other sites

Hi Jim

 

It didn't work. What did work though was to call a \r (return) instead of the \n (line break).

 

Thank you for your help though. It is always good to have assistance! ;)

Debbie Harrison

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...