OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Export orders into csv
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Order Total Modules
Pages: 1, 2
dlan
Hello All,
Some of you are contacting me regarding the module with some problems to get the file. I then create this topic so all the community can help if someone else already had a problem related and managed to find a solution.

David
hmiranda
Do you know how to export orders? I can't figure it out? I posted a question but maybe I didn't ask the right one. I am using a drop shipping company that I need to download my orders to my computer and then send the file to them.

It has to contain all the customer's information in addition to the order details. Am I in the right spot to find out information on how to do that?

Any help is appreciated!! Thanks! rolleyes.gif
gregp
Just posted a minor fix: in customers.php, the text

'<a href="' . tep_href_link(FILENAME_EXPORTORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_ORDERS . '</a>');

should be

'<a href="' . tep_href_link(FILENAME_EXPORTORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_EXPORTORDERS . '</a>');



Fixes a small error in /catalog/admin/includes/boxes/customers.php which causes the word 'Orders' to be shown twice in the Customers/Orders panel, with the bottom one activating the Export Orders function.

Replace

// BOF Export Orders to CSV
$contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CUSTOMERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_CUSTOMERS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_ORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_ORDERS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_EXPORTORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_ORDERS . '</a>');
// EOF Export Orders to CSV

with

// BOF Export Orders to CSV
$contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CUSTOMERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_CUSTOMERS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_ORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_ORDERS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_EXPORTORDERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CUSTOMERS_EXPORTORDERS . '</a>');
// EOF Export Orders to CSV

Nice contribution dlan!
simplytaty
Hi Dlan
Thank you so much, great contribuition. One question, actually two. I need to adf the type of shipping (expedited or standard) and total of the order to the download. Any resources on how to do that?
Thanks a bunch.
oxfamire
Hi Dlan

Thanks for the contribution, it's great, I just implemented it on our shop.

One question - is there a quick way to include the field names/table headers as part of the csv file?

Also, is there any way to add a currency option - so you can view the results in multiple currencies, or choose one currency to view all results in.

Thanks again - this will be a really useful contrib for us in months to come.
Dragonmom
I have implemented the contrib, and I get all of the buyer's information but none of the items that they've purchased. And that's what i need, since I offer custom-made goods-- I need the order number, the item and all of the options.

Any ideas?
dlan
QUOTE (simplytaty @ Oct 8 2007, 06:58 AM) *
Hi Dlan
Thank you so much, great contribuition. One question, actually two. I need to adf the type of shipping (expedited or standard) and total of the order to the download. Any resources on how to do that?
Thanks a bunch.


Hi,

Yes you can.In the export orders file, find the select query that selects the fields that should be exported. Just add the fields you want within the query (as long as they are in the same table. If this is not the case, you will have to join two tables). Then where you see "Queries 1" ... to 9 you can play with this to add the information you need.
Regarding your second question, I didn't really look into the file but you could add something like this that will display the number of exported orders on your page :

$reccount = (integer) mysql_query("Select COUNT(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");
echo 'Number of exported records : $reccount' ;

David
dlan
QUOTE (Dragonmom @ Nov 10 2007, 07:49 AM) *
I have implemented the contrib, and I get all of the buyer's information but none of the items that they've purchased. And that's what i need, since I offer custom-made goods-- I need the order number, the item and all of the options.

Any ideas?


Hi,
Normally you should get the description of the item. Have you modified in any way the exportorders.php?
David
peter_of_stirling
Hi all,

I can not get the data to download to my desktop. I have no trouble with getting the XML export to download to my desktop. I note with that script they use a dataexport folder within the admin folder. This contains an xml file.

I have never had any success with the cache setup.

Would this have any bearing on my problem?

I am not a php programmer but use cut and paste plus trial and error to achieve results.

Regards,
peter_of_stirling
oojacoboo
how do you filter by the order status....?
oojacoboo
I think adding in the filter from this contribution would be best. I tried to implement it, but, unfortunately my php skills are really quite limited... dry.gif

http://addons.oscommerce.com/info/4675
dlan
QUOTE (oojacoboo @ Nov 29 2007, 11:59 PM) *
how do you filter by the order status....?


Hi,
Simply by changing the orderby statement in your sql query in the exportorders.php file.
David
oojacoboo
I'm sorry, I don't see that statement in the exportorders.php file. Would you mind telling me what it says, or the line number? Maybe I have the wrong contribution file?

I see 9 Queries
- Order Comments
- Order Sub-Total
- Tax
- Insurance
- Shipping
- Giftwrap
- Order Total
- Product Count
- List of Products Ordered

I just don't see anything on here to filter out by Order Staus. I only want to export out Orders that have been paid for, via paypal, and OSC logs all orders even if the customer doesn't complete the order process...

Thanks!
Schadeboy
Hello, everyone.

I'm not sure if I'm missing something, but can someone tell me where the exported file is supposedly stored? I can't see anything anywhere on my site. When I run the script, after everything is said and done, I get a blank screen in my browser. Is this how this is supposed to work? Everyone else appears to have made it work properly. I don't know what I'm missing. The install seems fairly straight forward, so I just don't see what's wrong.

Thanks.

--------- UPDATE ---------

Nevermind. I was using an older version of the exportorders.php file. I downloaded the newest one and got the function working. Thanks to everyone who made this contrib! It will save me a ton of work.
Schadeboy
Okay, another thing. Now that I have the file exported, I need to include the attributes associted with our orders. Any way of doing this?

Also, I too would like to see column headers in the exported file. This would be extremely helpful.
peter_of_stirling
Hi Schadeboy

I note that you have succeeded!

I am still not having any thing download.

Which latest version are you using - is it the one with dropdown lists? If so, yes my orders do show both order no and date. I select a number of them but when I press Export to CSV the routine seems to run whilst the green bar is open at the bottom of the screen. It then throws me right out of /admin and brings me back to the admin log in screen.

I am not a php programmer and if I experiment I only seem to make matters worse.

I have also tried with several other contributions supposodly producing CSV also without success.

The only one that works is on http://www.mt-soft.com.ar/2007/07/02/php-script-mysqldump/.
This seems to use ob gzhandler instead of Generate CSV.

I am not clever enough to know how to adapt the ob gzhandler approach to David's script.

Any help would be appreciated!

Regards,
peter_of_stirling
QUOTE (Schadeboy @ Dec 1 2007, 07:28 AM) *
Hello, everyone.

I'm not sure if I'm missing something, but can someone tell me where the exported file is supposedly stored? I can't see anything anywhere on my site. When I run the script, after everything is said and done, I get a blank screen in my browser. Is this how this is supposed to work? Everyone else appears to have made it work properly. I don't know what I'm missing. The install seems fairly straight forward, so I just don't see what's wrong.

Thanks.

--------- UPDATE ---------

Nevermind. I was using an older version of the exportorders.php file. I downloaded the newest one and got the function working. Thanks to everyone who made this contrib! It will save me a ton of work.
nudylady
QUOTE (dlan @ Nov 30 2007, 12:22 PM) *
Hi,
Simply by changing the orderby statement in your sql query in the exportorders.php file.
David


I have 2 exportorders.php
catalog\admin\includes\languages\english\exportorders.php
catalog\admin\exportorders.php

which one to edit?

Can anyone tell me this statement?
nudylady
I have so many unpaid orders. I just wanna export paid PROCESSING status orders.
I am a dummy. I can't figure out what dlan said.
after 3 hours of trying. I added a order status colum after orders Id.
After export to excel. I delete orders not in Processing status. it worked.

here is what I have done:

open catalog\admin\exportorders.php

-------lines 115,119,123,127----------
after orders_id, add orders_status,

----line 136---------------
after $Orders_id = $row_orders["orders_id"];
add $Orders_status = $row_orders["orders_status"];

----line 275----------------
after $csv_output .= $Orders_id . "," ;
add $csv_output .= $Orders_status . "," ;

one thing I want to mention. in excel sheet pending shows as 1, processing shows as 2.
I dont know how to show the acctual word in steady of numbers.
peter_of_stirling
Hi David,

I am still trying to make your efforts work.

I have even installed it on to another clean domain without any success!

Conversely, the latest contribution of export customers worked without me needing to do any changes apart from those recommended.

Admittedly, that requires far less filtering than the full extraction of orders.

I note that with that code it starts with if (!_POST['submit']) instead of if (!$submitted || $submitted !=1)
and concludes with :-
header("Content-Type: application/force-download\n");
header("Content-Disposition: attachment; filename=exportsname_" . date("Ymd") . ".txt");
header("Pragma: no-cache");
header("Expires: 0");
echo $csv_output;
die();
}
require(DIR_WS_INCLUDES . 'application_bottom.php');
//function main
?>

I have tried applying some of these different ideas to your code - but still without success.

Any further ideas as to why I can not make it work will be appreciated!!

Regards,
peter_of_stirling
nudylady
QUOTE (peter_of_stirling @ Dec 4 2007, 08:37 AM) *
Hi David,

I am still trying to make your efforts work.

I have even installed it on to another clean domain without any success!


very strange.
try from another computer, a clean domain, on a different host must work.
serverguy
QUOTE (peter_of_stirling @ Dec 3 2007, 11:37 PM) *
Hi David,

I am still trying to make your efforts work.

I have even installed it on to another clean domain without any success!

Conversely, the latest contribution of export customers worked without me needing to do any changes apart from those recommended.

Admittedly, that requires far less filtering than the full extraction of orders.

I note that with that code it starts with if (!_POST['submit']) instead of if (!$submitted || $submitted !=1)
and concludes with :-
header("Content-Type: application/force-download\n");
header("Content-Disposition: attachment; filename=exportsname_" . date("Ymd") . ".txt");
header("Pragma: no-cache");
header("Expires: 0");
echo $csv_output;
die();
}
require(DIR_WS_INCLUDES . 'application_bottom.php');
//function main
?>

I have tried applying some of these different ideas to your code - but still without success.

Any further ideas as to why I can not make it work will be appreciated!!

Regards,
peter_of_stirling

I added this:
$submitted = $HTTP_POST_VARS['submitted'];
before:
if (!$submitted || $submitted != 1)
and now it processes, but the output is directly to the internet explorer screen. Along with that each order prints about 3 or 4 times into the window which makes for a big mess.

If I can't get it working it's on to searching for another.
leveera
Please advice, I'm looking for cont. to allow customers to get a copy of their orders in CSV. Is it a right one contrubution?

Thanks
Sergei
bongo
I have installed the Export all data to csv file version 2.2 and this works just fine. Can export orders and change what i should export.

But i have one question about it, when i export it i get all in one row.
Sow if the customer has 5 products on their order i get this on one line.

Does anyone of you now how i can make the export make a new line for each product on the order?

like this
Ordernumber Productid
1 120020
1 120021
1 120022

Hope that someone can help me with this.

And also a happy new year to everyone

-Thomas
razzer10
Ok, now I tried installing this contrib and am having problems getting it to download to my desktop as well. I used the most recent script and installed all thepatches. I am using RC2, don't know if that could be the problem? Looks like it works though, doesn't do anything weird, just seems the generate csv is not working...
janetgot
Hi, I'm hoping to get this contribution to work, however, when I use it, it only exports the customer contact information, and none of the order data (products info) is saved to the csv file. Here is my exportorders.php file. Any ideas?

CODE
<?php
/*
$Id: exportorders.php,v 1.1 April 21, 2006 Harris Ahmed $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 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 (!$submitted || $submitted != 1)
{
?>
<!-- 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><?php echo tep_draw_form('exportorders', FILENAME_EXPORTORDERS); ?>

<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 '&nbsp;&nbsp;' . tep_draw_pull_down_menu('start', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . '&nbsp;&nbsp;&nbsp;';

?></td>
</tr>
<tr>
<td><?php echo INPUT_END; ?></td>
<td><!-- <input name="end" size="5" value="<?php echo $end; ?>"> -->
<?php
echo '&nbsp;&nbsp;' . tep_draw_pull_down_menu('end', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . '&nbsp;&nbsp;&nbsp;';
?></td>
</tr>
<tr>
<td>&nbsp;</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>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</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($start, $end);
}

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

// 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_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 AND orders_id <= $end ORDER BY orders_id");
}
//patch

//$csv_output ="\n";
while ($row_orders = mysql_fetch_array($orders)) { //start one loop

$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
$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 .= $First_Name . "," ;
$csv_output .= $Last_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 from orders_products
where orders_id = " . $Orders_id);

// While loop to list the item

while($row_orders_products = mysql_fetch_array($orders_products)) {
$csv_output .= "," . "BEGIN_ITEM". "," ;
$csv_output .= filter_text($row_orders_products[0]) . "," ;
$csv_output .= $row_orders_products[1] . "," ;
$csv_output .= $row_orders_products[2] . "," ;
$csv_output .= filter_text($row_orders_products[3]) . "," ;
$csv_output .= "END_ITEM";

} // 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
?>
stunter
QUOTE (bongo @ Jan 1 2008, 10:20 AM) *
I have installed the Export all data to csv file version 2.2 and this works just fine. Can export orders and change what i should export.

But i have one question about it, when i export it i get all in one row.
Sow if the customer has 5 products on their order i get this on one line.

Does anyone of you now how i can make the export make a new line for each product on the order?

like this
Ordernumber Productid
1 120020
1 120021
1 120022

Hope that someone can help me with this.

And also a happy new year to everyone

-Thomas



This is the exact issue that I have been struggling with. This contribution only seems to work if there is only one product ordered at a time, which doesn't help. Someone please help us with this. Thanks!
eppie13
I would like to put the invoice number also in the csv file. I put this: $csv_output .= $Num_invoice . "," ; in the CSV settings but I think I also have to make a query? Can you help me out?

Kind regards,
Esther
stubbsy
Hi there,

I've been using the contribution for some time now, I use it every day to export data to upload to parcelforce to print dispatch labels.

I was wondering if it would be possible to have the option be able to export a string of orders, not neccessarily in order, eg 1,3,10,11,19,40 etc rather than a range.

Any ideas how this could be acheived?

Thanks

Dave
dlan
QUOTE (oojacoboo @ Nov 30 2007, 09:51 PM) *
I'm sorry, I don't see that statement in the exportorders.php file. Would you mind telling me what it says, or the line number? Maybe I have the wrong contribution file?

I see 9 Queries
- Order Comments
- Order Sub-Total
- Tax
- Insurance
- Shipping
- Giftwrap
- Order Total
- Product Count
- List of Products Ordered

I just don't see anything on here to filter out by Order Staus. I only want to export out Orders that have been paid for, via paypal, and OSC logs all orders even if the customer doesn't complete the order process...

Thanks!



Hi,

Sorry for the long reply I haven't been around for a while.
The orderby statement should be placed at the end of your sql query.
Here is a simple example :
SELECT * FROM tablenamegoeshere ORDERBY fieldnamegoeshere
So in the files, you have queries that are selecting the orders, simply add ORDERBY followed by the field you want to sort between quotes.
dlan
QUOTE (leveera @ Dec 17 2007, 10:01 AM) *
Please advice, I'm looking for cont. to allow customers to get a copy of their orders in CSV. Is it a right one contrubution?

Thanks
Sergei


Hi,

Not just as is but you can modify the contribution to get what you want. This would be like creating a little new contrib adding a customer field in order to select the customer name and then modifying the query so it selects only the orders of this selected customer.
dlan
QUOTE (bongo @ Jan 1 2008, 04:20 PM) *
I have installed the Export all data to csv file version 2.2 and this works just fine. Can export orders and change what i should export.

But i have one question about it, when i export it i get all in one row.
Sow if the customer has 5 products on their order i get this on one line.

Does anyone of you now how i can make the export make a new line for each product on the order?

like this
Ordernumber Productid
1 120020
1 120021
1 120022

Hope that someone can help me with this.

And also a happy new year to everyone

-Thomas



Hi,

Yes this is normal as this is exporting the total of the order.
If you want to get the product lines, you will need to modify the queries and add a join with the product table and possibly the customers table to get the product id, ...
dlan
QUOTE (janetgot @ Jan 28 2008, 03:44 PM) *
Hi, I'm hoping to get this contribution to work, however, when I use it, it only exports the customer contact information, and none of the order data (products info) is saved to the csv file. Here is my exportorders.php file. Any ideas?

CODE
<?php
/*
$Id: exportorders.php,v 1.1 April 21, 2006 Harris Ahmed $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 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 (!$submitted || $submitted != 1)
{
?>
<!-- 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><?php echo tep_draw_form('exportorders', FILENAME_EXPORTORDERS); ?>

<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 '&nbsp;&nbsp;' . tep_draw_pull_down_menu('start', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . '&nbsp;&nbsp;&nbsp;';

?></td>
</tr>
<tr>
<td><?php echo INPUT_END; ?></td>
<td><!-- <input name="end" size="5" value="<?php echo $end; ?>"> -->
<?php
echo '&nbsp;&nbsp;' . tep_draw_pull_down_menu('end', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . '&nbsp;&nbsp;&nbsp;';
?></td>
</tr>
<tr>
<td>&nbsp;</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>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</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($start, $end);
}

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

// 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_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 AND orders_id <= $end ORDER BY orders_id");
}
//patch

//$csv_output ="\n";
while ($row_orders = mysql_fetch_array($orders)) { //start one loop

$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
$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 .= $First_Name . "," ;
$csv_output .= $Last_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 from orders_products
where orders_id = " . $Orders_id);

// While loop to list the item

while($row_orders_products = mysql_fetch_array($orders_products)) {
$csv_output .= "," . "BEGIN_ITEM". "," ;
$csv_output .= filter_text($row_orders_products[0]) . "," ;
$csv_output .= $row_orders_products[1] . "," ;
$csv_output .= $row_orders_products[2] . "," ;
$csv_output .= filter_text($row_orders_products[3]) . "," ;
$csv_output .= "END_ITEM";

} // 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
?>


Hi,

If you want to export other data, you need to modify the queries within the file (SELECT ...) and play with SQL to get the data you need.
dlan
QUOTE (stunter @ Jan 29 2008, 03:10 AM) *
This is the exact issue that I have been struggling with. This contribution only seems to work if there is only one product ordered at a time, which doesn't help. Someone please help us with this. Thanks!



Hi,

those are two different things. If you want the detail of the order then yes, you need to modify the queries in order to extract the data you like. The way it is done so far is that it exports the total of the order so if you have two products within it, you will get only one line with the total amount for the two products.
dlan
QUOTE (eppie13 @ Feb 26 2008, 04:07 PM) *
I would like to put the invoice number also in the csv file. I put this: $csv_output .= $Num_invoice . "," ; in the CSV settings but I think I also have to make a query? Can you help me out?

Kind regards,
Esther


Hi,

Yes you need to select the corresponding invoice number in the export orders query. I have not looked into it so I don't know if the invoice number is in the table we are querying here. If yes, simply add the name of the field within the query, if not then you might have to make a join.
dlan
QUOTE (stubbsy @ Feb 28 2008, 01:24 PM) *
Hi there,

I've been using the contribution for some time now, I use it every day to export data to upload to parcelforce to print dispatch labels.

I was wondering if it would be possible to have the option be able to export a string of orders, not neccessarily in order, eg 1,3,10,11,19,40 etc rather than a range.

Any ideas how this could be acheived?

Thanks

Dave


Hi,

sure thing, you can barely do whatever you like :-) You can change the queries that are in the exportorders.php file and even make another little contrib so it exports exactly what you want.
dlan
QUOTE (dlan @ Mar 3 2008, 02:23 PM) *
Hi,

Sorry for the long reply I haven't been around for a while.
The orderby statement should be placed at the end of your sql query.
Here is a simple example :
SELECT * FROM tablenamegoeshere ORDERBY fieldnamegoeshere
So in the files, you have queries that are selecting the orders, simply add ORDERBY followed by the field you want to sort between quotes.


Oups ... no quotes sorry and it is being spellet ORDER BY (space between order and by) :-)
lambro
I seem to be having problems with long numbers, for example telephone and credit card numbers. A phone number comes out as 2.09E+09 in the excel box, but when you high light it it reads 2086405970 in the formula bar (this is nearly correct, it is missing the leading 0).
sps-merlin
excellent contrib. i'm needing to alter the order of how things display in the exported .csv file. i have a pretty good idea of what i need to do in terms of the php and can join tables if i need to but i don't know where in the .php file i need to be looking for that aspect of the script. could anyone please advise? i'm using the latest downloadable version
steven78
Who can help me? This script was working well; and after a change to another server this great contribution isn't working anymore.

I have RC1

I can use the contrib but after pressing 'Generate' nothing is happening; only the url gives: export_orders_csv.php?start=800&end=850&status=&submitted=1

Does anyone have the same problem?
sps-merlin
can anyone offer any help for altering the order in which the fields are displayed in .csv export. i would imagine this is easy enough but i don't know where in the php file to make the appropriate alterations
nimloth
I can not find any "exportorders" referenc es or files in my installation, which is the durrent one. Where can I get this module...in English???
steven78
Does anyone have a solution for this?
sps-merlin
Is there any reason this wouldn't work on an xampp localhost install? it works fine on my live site but i want to run a test site locally via xampp and it doesn't work. i've installed it the same as on my live site but when i click to process the csv (either to a file or to the screen) it doesn't appear to do anything other than essentially a screen refresh

any ideas please?
sps-merlin
QUOTE (sps-merlin @ Mar 28 2008, 11:10 AM) *
Is there any reason this wouldn't work on an xampp localhost install? it works fine on my live site but i want to run a test site locally via xampp and it doesn't work. i've installed it the same as on my live site but when i click to process the csv (either to a file or to the screen) it doesn't appear to do anything other than essentially a screen refresh

any ideas please?


this was a register_globals issue... fixed
dlan
QUOTE (sps-merlin @ Mar 7 2008, 07:42 PM) *
excellent contrib. i'm needing to alter the order of how things display in the exported .csv file. i have a pretty good idea of what i need to do in terms of the php and can join tables if i need to but i don't know where in the .php file i need to be looking for that aspect of the script. could anyone please advise? i'm using the latest downloadable version


Hi,
Sorry for the long delay ...
You need to change the exportprder.php file, it is the one that contains the queries and that creates the CSV file.
Regards,
dlan
QUOTE (nimloth @ Mar 18 2008, 06:07 AM) *
I can not find any "exportorders" referenc es or files in my installation, which is the durrent one. Where can I get this module...in English???


Hi,
You will find the full package in the contribs area on the main osc website. Search for "export orders into csv".
Full package is available under the first link "Export Orders into CSV v2.0" then other people have corrected a few things that you may want to implement.
Regards,
dlan
QUOTE (steven78 @ Mar 14 2008, 04:24 PM) *
Who can help me? This script was working well; and after a change to another server this great contribution isn't working anymore.

I have RC1

I can use the contrib but after pressing 'Generate' nothing is happening; only the url gives: export_orders_csv.php?start=800&end=850&status=&submitted=1

Does anyone have the same problem?

Hi,
Sorry I don't have this problem. Have you checked that your new server is actually having the exact same configuration as the old one? Take a look at your php.ini and mainly at the register_globals option.
Regards,
lambro
Still have this problem, any one?

I seem to be having problems with long numbers, for example telephone and credit card numbers. A phone number comes out as 2.09E+09 in the excel box, but when you high light it it reads 2086405970 in the formula bar (this is nearly correct, it is missing the leading 0).
laracameron
I was having the same problem as a few others here. I installed the most recent version of this add-on but wasn't being prompted to download a CSV file after clicking 'Export to CSV'. I know little about PHP but I showed my expert brother and he said:

"There was a bug in the code - it used an old rarely supported PHP feature, of turning form fields directly into variables."

He modified the "exportorders.php" file for me and now it works. I've added it as a download here so hopefully it will work for you too!
laracameron
QUOTE (lambro @ Apr 8 2008, 09:33 AM) *
Still have this problem, any one?

I seem to be having problems with long numbers, for example telephone and credit card numbers. A phone number comes out as 2.09E+09 in the excel box, but when you high light it it reads 2086405970 in the formula bar (this is nearly correct, it is missing the leading 0).



Isn't that just because the size of the field is too small? So when you expand it the full number appears? I just noticed that happening in Excel and haven't read the previous posts so maybe you and I are talking about two completely different things - (if so sorry smile.gif )
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.