Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Writing Order to a File on the Server? 17 days - Please help


ecroskey

Recommended Posts

Is there any way to write each order to it's own file on the webserver?

 

I am assuming I can add something to the checkout_process.php but I don't know where to begin.

 

Also, can someone please point me in the right direction to re-write the information that is sent out in the confirmation email? I know that info is in the checkout_process.php also, but when I try to edit the format I just lose all the information.

 

I have 17 days to finish this thing up.

 

Thank You All.

 

Regards,

Eric

Link to comment
Share on other sites

Is there any way to write each order to it's own file on the webserver?

 

I'm a bit confused...why would you want to do that? Each order already has it's own unique ID in the database.

 

Also, can someone please point me in the right direction to re-write the information that is sent out in the confirmation email? I know that info is in the checkout_process.php also, but when I try to edit the format I just lose all the information.

 

The email is "put together" in checkout_process.php and you can change the language in the corresponding language file. What do you want to do with the confirmation, what kind of changes are you trying to make?

Link to comment
Share on other sites

I have to have flat files because we process all of our orders in-house on a mainframe. I need to pass those files in a certain format over to the MF.

 

I was thinking that if I could rearrange the email that is sent back to me, I could just use that as my flat file. I need it to be in the following format:

 

Date

Billing First Name

Billing Last Name

Billing Address

Billing City

Billing State

Billing Postal Code

Billing Country

----You Get the idea----

Mailing ------

----You get the idea ----

Credit Card Info

Order Quantity

Order Subtotal

Quantity Discount

Sales Tax

Shipping COsts

Order Total

 

 

Item No.

Product (Name)

Options

Price

Qty

Tax

Shipping

Total

 

It has to be in that format for the MF to process the order.

 

Regards,

Eric

Link to comment
Share on other sites

Oh boy! This si getting out of my realm but, I don't hink changing the confirmation email is the best way to go. What you get is just exactly what the customer gets and if they get an email fromatted the way you're talking I think it would be very confusing to them.

 

Can you use a comma seperated values list for the main frame?

Link to comment
Share on other sites

It should be fairly straigtforward create a little php script to do a SQL query after the order is placed, and create a text file in the format you need, and either email it to you or have it ready for download.

 

Does this make sense to you?

Unexpect the Expected

Link to comment
Share on other sites

mouflon

 

 

Let's say it makes sense in theory. I have actually been trying to do this since my last post. I have found the fopen will create a text file on the server, but I haven't made much prgress. I am still just unsure of programming in php, so I am wasting a lot of time trying to figure out how to do things, and not actually accomplishing them.

 

One thing I was thinking about doing is this:

 

$sql = 'SELECT * FROM orders WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date_purchased ) <= 1 LIMIT 0, 30';

 

This will at least limit my orders to what happened each day.

 

Here are some questions though:

1)When I select the orders, how can I select the orders from the previous day? I haven't been able t ofigure that part out. I do the orders each morning for the previous day.

 

2)How do I display this info in the form I want (see above). Obviously all of the information is there, but I am not sure how to display it.

 

3)Has anyone used fopen before to create a file on the server?

 

Here's what I have so far, any help debugging would be greatly appreciated.

 

<?php

// define where to send orders

$OrdDir ='/var/www/cgi-bin/orders';

 

// define our database connection

define('DB_SERVER', 'localhost'); // eg, localhost - should not be NULL for productive servers

define('DB_SERVER_USERNAME', 'xxxxx');

define('DB_SERVER_PASSWORD', 'xxxxx');

define('DB_DATABASE', 'catalog');

define('USE_PCONNECT', 'false'); // use persisstent connections?

define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'

 

$sql = 'SELECT * FROM orders WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date_purchased ) <= 1 LIMIT 0, 30';

 

New Order:

 

Date = %%now%%

Billing First Name = %%B_FNAME%%

Billing Last Name = %%B_LNAME%%

Billing Address = %%B_ADDRESS%%

Billing City = %%B_CITY%%

Billing State = %%B_STATE%%

Billing Postal Code = %%B_ZIP%%

Billing Country = %%B_COUNTRY%%

Billing Phone Number = %%B_PHONE%%

Billing Email Address = %%B_EMAIL%%

Mailing First Name = %%M_FNAME%%

Mailing Last Name = %%M_LNAME%%

Mailing Name = %%M_NAME%%

Mailing Address = %%M_ADDRESS%%

Mailing City = %%M_CITY%%

Mailing State = %%M_STATE%%

Mailing Postal Code = %%M_ZIP%%

Mailing Country = %%M_COUNTRY%%

Mailing Phone Number = %%M_PHONE%%

Card Type = %%CARDTYPE%%

Card Name = %%CARDNAME%%

Card Number = %%CARDNUM%%

Card Expiration Month = %%EXPDATE_MM%%

Card Expiration Year = %%EXPDATE_YY%%

Order Quantity = %%AOQn%%

Order Subtotal = $%%Asub%%

Quantity Discount = $0.00

Sales Tax = $%%Atax%%

Shipping Costs = $%%Aship%%

Order Grand Total = $%%Atot%%

User Host IP Address = %%UID%%

 

 

";

 

// writes the order to a file on the server

$file="$OrdDir/somename";

$f=fopen($file,'w');

fwrite($f,$ORDfileP1);

fwrite($f,$ORDfileItems);

fwrite($f,$ORDFilefree);

fclose($f);

 

 

?>

Link to comment
Share on other sites

OK , here's pseudo code for what you need to do:

 

query orders  

get all date_purchased dates from orders

build select list with those dates

 

fopen(f$,filename for writing)

 

submit form to....

execute query on orders for date_purchased  

 

while query is true{

assign all fields to variables

 

execute query on orders_products for orders_products_id

assign all fields to variables

 

execute query on orders_total for orders_products_id

assign all fields to variables

 

fwrite($f,$variable1."n");  

fwrite($f,$variable2."n");  

and so on

if you need a blank line

fwrite($f,"n");  

 

}

fclose(filename)

 

What you now do with that file is pretty important. You should create it somewhere outside of your web space, because you now have a plain text file with users names and credit card information. I would probably download the file immediately, probably built into the script, then have the script delete the file.

 

I'm kinda short on time today, but if you need help, I can probably put a script together for you. Just let me know the exact format (line breaks or carriage returns, blank lines, etc.)

Unexpect the Expected

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...