Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

printing packing slips instead of email notification?


Guest

Recommended Posts

Greetings,

I've searched the forum to the best of my ability, scoured the knowledge base and looked at every contribution that looked like it may work. To no avail. Of course I might have missed something.

 

What I need to do is have orders printed as they arrive from customers instead of (or in addition to) sending an email to the admin. The packing slip would be fine as it appears in Admin->Customers->Orders, but as far as I can tell, that packing slip requires manual intervention for retrieval. I need the thing to go to the server's default printer as soon as an order arrives.

 

The call to the printer is a simple command line call to lpr so I can code it myself if necessary. But of course, if someone has already invented that wheel I'd rather spend my time on something else.

 

I've considered automating the printing on the admin's email account via a procmail script, but I'm saving that for a last resort since it involves a pretty large amount of rigamarole.

 

If any one has any suggestions or can help in any way I'd be most grateful.

 

Thanks in advance.

Link to comment
Share on other sites

Greetings,

I've searched the forum to the best of my ability, scoured the knowledge base and looked at every contribution that looked like it may work. To no avail. Of course I might have missed something.

 

What I need to do is have orders printed as they arrive from customers instead of (or in addition to) sending an email to the admin. The packing slip would be fine as it appears in Admin->Customers->Orders, but as far as I can tell, that packing slip requires manual intervention for retrieval. I need the thing to go to the server's default printer as soon as an order arrives.

 

The call to the printer is a simple command line call to lpr so I can code it myself if necessary. But of course, if someone has already invented that wheel I'd rather spend my time on something else.

 

I've considered automating the printing on the admin's email account via a procmail script, but I'm saving that for a last resort since it involves a pretty large amount of rigamarole.

 

If any one has any suggestions or can help in any way I'd be most grateful.

 

Thanks in advance.

 

Ok fine.

 

I modifed catalog/checkout_process.php to meet my requirement. It prints the contents of the admin email to the server's default printer. I realize that most of us don't host our own sites, and for those of us who do many probably have the server in a DMZ - either way I'm sure that the vast majority of the people here won't have any use for this code.

 

In catalog/checkout_process.php just after this section:

 

// send emails to other people
 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 }

 

I added the following code:

 

// begin print order PHP4 version
//build a filename including the order number
$filename = "/tmp/webStoreOrder" . $order_products_id . ".dat";

$handle = fopen($filename, 'x');

// additional optional header for printing
$print_head = "\nYOUR STORENAME packing slip \nTHANKS!\n ";
$email_order = "$print_head . $email_order";
fwrite($handle, $email_order);

// send the file to the default printer
$output = shell_exec("lpr $filename");
// end print order

 

There is probably a way to do this without creating a file, but I was in a hurry and this works fine so it will have to do. I'm entirely open to suggestions for more efficient alternatives.

 

This mod depends on the web server user having write access to /tmp. Your path may have to vary depending on your environment. It also assumes a UNIX-like server with the lpr command line utility available.

 

 

BTW, PHP5 has a nice new function

 

int file_put_contents(file,contents)

 

which takes care of all that filehandle stuff.

 

So, would there be much point in making this into a contribution?

Link to comment
Share on other sites

  • 3 years later...

atoms--

 

Thanks for your posts. 3.5 years later, I'm trying to send the customer order to a remote printer with a static ip address. I'm not the site host, so I do not believe I have the access I need to make this work. Do you have any suggestions, given your experience? Thanks!

 

--b

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...