Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] PDF Customer Invoice


chris23

Recommended Posts

Hi again,

 

the PDF invoices are working fine now (and looking great), but I cannot get the e-mail attachment contrib to work. This is what I get after installing everything according to instructions:

Fatal error: Cannot redeclare class order in /homepages/27/d122832506/htdocs/catalog/includes/classes/order.php on line 13

This error message comes up when the checkout_process.php is including pdf_invoice.php. (When I comment out the include, the error does not show, but of course I don't get an e-mail attachment either).

 

Any ideas?

 

Many thanks

Reiner

Edited by Pipeloops
Link to comment
Share on other sites

Hi again,

 

the PDF invoices are working fine now (and looking great), but I cannot get the e-mail attachment contrib to work. This is what I get after installing everything according to instructions:

Fatal error: Cannot redeclare class order in /homepages/27/d122832506/htdocs/catalog/includes/classes/order.php on line 13

This error message comes up when the checkout_process.php is including pdf_invoice.php. (When I comment out the include, the error does not show, but of course I don't get an e-mail attachment either).

 

Any ideas?

 

Many thanks

Reiner

 

 

Did you do this step in pdfinvoice.php?

 

FIND:

 

require('includes/application_top.php');

 

REPLACE WITH:

 

// prevents reinclusion if called from checkout_process.php
require_once('includes/application_top.php');

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

If you want to be able to date your PDF Invoice with the date the order status is set to "Delivered", this is for you:

 

1. Backup, Backup, Backup - including your MySQL

 

2. Run the following via phpMyAdmin:

 

update configuration set configuration_description='Do you want the invoice date to be today''s date, the date of order or the date order is updated to status "Delivered"? [ Default = today ]', set_function='tep_cfg_select_option(array(''today'', ''order'', ''delivered''),' where configuration_key='PDF_INV_DATE_TODAY';

3. EDIT pdfinvoice.php

FIND:

 

// set invoice date - today or day ordered. set in config
$date = (PDF_INV_DATE_TODAY == 'today') ? strftime(DATE_FORMAT_LONG) :
tep_date_long($order->info['date_purchased']);

REPLACE WITH:

 

// set invoice date - today, date ordered or date order status set to "Delivered". Set in config
switch (PDF_INV_DATE_TODAY){
case 'today':
	$date = strftime(DATE_FORMAT_LONG);
	break;
case 'order':
	$date = tep_date_long($order->info['date_purchased']);
	break;
case 'delivered':
	$delivered_query = tep_db_query("select last_modified from " . TABLE_ORDERS . " where orders_id='" . (int)$_GET['order_id'] . "' and orders_status='3'");
	$delivered_status = tep_db_fetch_array($delivered_query);
	if (!tep_db_num_rows($delivered_query)){
		$date = strftime(DATE_FORMAT_LONG);
	} else {
		$date = tep_date_long($delivered_status['last_modified']);
	}
	break;
}

You'll now have an extra option, 'delivered', under Admin -> PDF Invoices -> Choose invoice date

Notes

-------

 

If you generate an invoice admin side and the order status is set to any status but "Delivered", the PDF falls back to today's date.

 

On the customer side, this won't be an issue if you set 'Only display invoice for delivered orders?' to true.

 

This mod assumes your orders_status_id for 'Delivered' is the default value of 3

 

HTH

 

Chris

 

Thank you for your help,

but a problem with my DB does not appear that the option of selecting admin.

I want something easier to bring the date elsewhere; I think of something like this:

 

	$pdf->Text(10,118, tep_html_entity_decode(PRINT_INVOICE_TITLE) . tep_html_entity_decode($order->billing['invoice_serial'].$order->billing['invoice_number_pad'] ));
 $statuses_query = tep_db_query("select os.orders_status_name, osh.date_added, osh.comments from " . TABLE_ORDERS_STATUS . " os, " . TABLE_ORDERS_STATUS_HISTORY . " osh where osh.orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "' and osh.orders_status_id = os.orders_status_id and os.language_id = '" . (int)$languages_id . "' order by osh.date_added");
 while ($statuses = tep_db_fetch_array($statuses_query)) {
$pdf->Text(60,118, tep_html_entity_decode(PRINT_INVOICE_DATE1) . tep_date_short($statuses['date_added']));
}

 

PRINT_INVOICE_TITLE = Factura nº:

PRINT_INVOICE_DATE1 = Fecha de factura:

 

This code is what I have drawn from account_history_info.php, but it is not correct because doubles and overrides the text and date.

I do not know anything about php.

 

Greetings.

Eusebio.

Link to comment
Share on other sites

Did you do this step in pdfinvoice.php?

 

FIND:

 

require('includes/application_top.php');

 

REPLACE WITH:

 

// prevents reinclusion if called from checkout_process.php
require_once('includes/application_top.php');

 

Hello Chris,

 

yes, I did. Without that step there is a similar error, but it is complaining about "do_magic_something" being redeclared.

 

Thanks

Reiner

Link to comment
Share on other sites

Hello Chris,

 

yes, I did. Without that step there is a similar error, but it is complaining about "do_magic_something" being redeclared.

 

Thanks

Reiner

 

OK, my error in the instructions. You'll need to edit pdfinvoice.php and change

 

require(DIR_WS_CLASSES . 'order.php');

 

to

 

require_once(DIR_WS_CLASSES . 'order.php');

 

missed that one, though mine works (strangely)

 

That ought to do it

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

OK, my error in the instructions. You'll need to edit pdfinvoice.php and change

 

require(DIR_WS_CLASSES . 'order.php');

 

to

 

require_once(DIR_WS_CLASSES . 'order.php');

 

missed that one, though mine works (strangely)

 

That ought to do it

 

Cool, that did it! Now its doing something, but I guess I must be missing something else. The mail it sends looks like this:

 

--=_28e0c4fa905bcc4a9d7275829eee1b27

Content-Type: application/octet-stream

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="pipeloops_invoice_78.pdf"

 

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy

IDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3VidHlwZSAvTGluayAvUmVjdCBbMTkuODQg

ODEzLjU0IDE1MC40NiA3NTYuOTFdIC9Cb3JkZXIgWzAgMCAwXSAvQSA8PC9TIC9VUkkgL1VSSSAo

...

 

any idea?

 

Thanks

Reiner

Link to comment
Share on other sites

Cool, that did it! Now its doing something, but I guess I must be missing something else. The mail it sends looks like this:

 

--=_28e0c4fa905bcc4a9d7275829eee1b27

Content-Type: application/octet-stream

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="pipeloops_invoice_78.pdf"

 

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy

IDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3VidHlwZSAvTGluayAvUmVjdCBbMTkuODQg

ODEzLjU0IDE1MC40NiA3NTYuOTFdIC9Cb3JkZXIgWzAgMCAwXSAvQSA8PC9TIC9VUkkgL1VSSSAo

...

 

any idea?

 

Thanks

Reiner

 

Yep,

 

Which email client are you using? I suspect it's a text based one. An email client when given a content type of application/octet-stream normally infers the file type from the filename extension. You're probably using web mail(?)

 

You can force a mime type of application/pdf:

 

EDIT includes/functions/general.php

 

 

FIND

 

 

$message->add_string_attachment($string, $filename);

 

and REPLACE with

 

$message->add_string_attachment($string, $filename, 'application/pdf');

 

This is probably a better default - I'll update the instructions

 

 

HTH

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Yep,

 

Which email client are you using? I suspect it's a text based one. An email client when given a content type of application/octet-stream normally infers the file type from the filename extension. You're probably using web mail(?)

 

You can force a mime type of application/pdf:

 

EDIT includes/functions/general.php

FIND

$message->add_string_attachment($string, $filename);

 

and REPLACE with

 

$message->add_string_attachment($string, $filename, 'application/pdf');

 

This is probably a better default - I'll update the instructions

HTH

 

Sorry, still doesn't work. I am reading the mail using Outlook Express and/or Outlook. I get the following mail header:

Return-Path: <[email protected]>
Delivery-Date: Wed, 20 Feb 2008 08:33:12 +0100
Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.179])
by mx.kundenserver.de (node=mxeu11) with ESMTP (Nemesis)
id 0MKuA8-1JRjS43At3-0005rW for [email protected]; Wed, 20 Feb 2008 08:33:12 +0100
Received: from infong321.kundenserver.de (infong321.kundenserver.de [212.227.119.138])
by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis)
id 0MKwtQ-1JRjS42Lmb-0005Xe; Wed, 20 Feb 2008 08:33:12 +0100
Received: from 129.247.247.238 (IP may be forged by CGI script)
by infong321.kundenserver.de with HTTP
id 4AgDh9-1JRjS41zSh-0004Ej; Wed, 20 Feb 2008 08:33:12 +0100
X-Sender-Info: <[email protected]>
Date: Wed, 20 Feb 2008 08:33:12 +0100
Message-Id: <[email protected]>
Precedence: bulk
To: " " <[email protected]>
Subject: Bestellung
From: "Pipeloops (Reiner Suikat)" <[email protected]>
MIME-Version: 1.0
X-Mailer: osCommerce
Content-Type: multipart/mixed;
boundary="=_355b273d559c249fb1306f8c45b4b9d4"
X-Provags-ID: V01U2FsdGVkX191QWA4kLHWINREIKM65+wZDyFlHhMJjrwj4H4
+chpAWE58MeGzeewWIu6+9uMZioqVT4eFUf/Tb5/Ra6R2AeTTJ
6T63Ti6KLmcqBC6vWdEzQ==
X-PhishingScore:   0
tests= 
X-SpamScore: 2.9
tests= TVD_SPACE_RATIO
Envelope-To: [email protected]

 

The mail itself:

--=_355b273d559c249fb1306f8c45b4b9d4
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="pipeloops_invoice_79.pdf"

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy
IDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3VidHlwZSAvTGluayAvUmVjdCBbMTkuODQg
ODEzLjU0IDE1MC40NiA3NTYuOTFdIC9Cb3JkZXIgWzAgMCAwXSAvQSA8PC9TIC9VUkkgL1VSSSAo

 

It also seems that the mail only contains the binary code, I cannot find the normal text.

 

Totally confused

 

Reiner

Link to comment
Share on other sites

It also seems that the mail only contains the binary code, I cannot find the normal text.

 

Totally confused

 

 

 

Reiner

 

 

I found it! I had the option "send e-mail as html" set to "true" in my shop configuration. Changing it to "false" solved the problem. The invoice now comes as attachment.

 

Thanks for this neat contrib!

 

Regards

Reiner

Link to comment
Share on other sites

Hi Chris, thanks for the attachment addition and your PM on it. I didn't expect it so soon :)

 

but.... I can't get it working (yet), here's my troubleshooting so far:

Triggered to "on" in the ACP.....

On Test orders, instead of seeing the "success page" when completing an order I see "my order history page" then No email w/ attachment is sent, not even the normal order confirmation email.

 

Switching back in the ACP to attach=false the basic email is again sent, order seems normal.

Went over the install 3 times. Any ideas????

osCommerce 2.2-MS2

PHP Version 4.3.9

 

 

Hi KJ, Hi Chris,

Just wanted to ask if you managed to figure this one out. I have the same problem. I too have checked my install steps to no avail.

 

Any help would be much appreciated.

 

thank you Chris for this awesome contrib.

Link to comment
Share on other sites

Hi KJ, Hi Chris,

Just wanted to ask if you managed to figure this one out. I have the same problem. I too have checked my install steps to no avail.

 

Any help would be much appreciated.

 

thank you Chris for this awesome contrib.

 

Hi Rob,

 

Two things:

 

1. Have you applied the two latest fixes - check the contrib area? These fixes are also posted above. If you haven't, please try these first

 

2. Are you getting bounced to account_history.php the same as KJ or are you ending up somewhere else? I can't see how this is happening from checkout_process.php

 

Cheers

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

I found it! I had the option "send e-mail as html" set to "true" in my shop configuration. Changing it to "false" solved the problem. The invoice now comes as attachment.

Reiner

 

Weird - mine works with this set false or true. Well at least you've got it working. I thought it was just me who'd got it to work :-"

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Hi guys

I tried the email as text in ACP, still no email sent, after test order completes it goes to the order history page instead of the checkout_suceess.php page. still? ;( ugh

 

My ACP email options are set as:

E-Mail Transport Method: sendmail

E-Mail Linefeeds: LF

Use MIME HTML When Sending Emails: true

Verify E-Mail Addresses Through DNS: true

Send E-Mails: true

 

I have no other mod that would direct customers to the order history page upon complettion of an order. When I trigger the "attatch pdf email" to false all is correct, the test order goes to the checkout_success, I get the order email (with no pdf of course!)

 

Let me know what else you want tried/trouble-shooted and I will :)

 

KJ

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Let me know what else you want tried/trouble-shooted and I will :)

 

Hi KJ,

 

Did you get my e-mail reply to the message you sent with your files attached?

 

I looked through your files and all looks fine.

 

I'm really confused as to why you're getting bounced to account history, though you do hava another conrtibution in checkout_process.php which may be an issue.

 

Rgds

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Hi Rob,

 

Two things:

 

1. Have you applied the two latest fixes - check the contrib area? These fixes are also posted above. If you haven't, please try these first

 

2. Are you getting bounced to account_history.php the same as KJ or are you ending up somewhere else? I can't see how this is happening from checkout_process.php

 

Cheers

 

Chris

 

Hi Chris,

 

I have applied the latest fixes.

 

It looks to me like my problem is the same as KJ's. With send pdf invoice attatch set to false in admin, all works as normal with confirmation email sent.

 

With send pdf invoice attatch set to true, after clicking on continue (checkout_confirmation.php) I am taken to account_history.php the order made appears in the account_history list and the products remain in the shopping cart, with no confirmation email sent to customer. The order is confirmed on admin end and emails to notify store owner are sent.

 

Cheers

Link to comment
Share on other sites

Hi Chris,

 

I have applied the latest fixes.

 

It looks to me like my problem is the same as KJ's. With send pdf invoice attatch set to false in admin, all works as normal with confirmation email sent.

 

With send pdf invoice attatch set to true, after clicking on continue (checkout_confirmation.php) I am taken to account_history.php the order made appears in the account_history list and the products remain in the shopping cart, with no confirmation email sent to customer. The order is confirmed on admin end and emails to notify store owner are sent.

 

Cheers

 

Rob,

 

Apologies to you. Now you've confirmed the same problem as KJ, I can see exactly what's happening.

 

I've changed my osc test system to be PHP5 ready which means I've replaced all instances of $HTTP_GET_VARS and $HTTP_POST_VARS to their superglobal equivalents, $_GET and $_POST.

 

What I've done, without thinking, is use $_GET in checkout_process.php instead of $HTTP_GET_VARS. What's happening in your case is no order id is being passed to pdfinvoice.php so it thinks it's being hacked and bounces you to account_history, as it should.

 

To fix this,

 

EDIT checkout_process.php

 

FIND

 

$_GET['order_id'] = $insert_id;

 

and change to:

 

$HTTP_GET_VARS['order_id'] = $insert_id;

 

This should 'GET' you (c**p pun), up and running!

 

Sincere apologies. This is why I ask for people's PHP versions as many are making the move to PHP5 and unpredictable behaviours like this are happening.

 

 

@KJ This is your problem too! Sorry ....

 

Cheers

 

Chris

Edited by chris23

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Rob,

 

Apologies to you. Now you've confirmed the same problem as KJ, I can see exactly what's happening.

 

I've changed my osc test system to be PHP5 ready which means I've replaced all instances of $HTTP_GET_VARS and $HTTP_POST_VARS to their superglobal equivalents, $_GET and $_POST.

 

What I've done, without thinking, is use $_GET in checkout_process.php instead of $HTTP_GET_VARS. What's happening in your case is no order id is being passed to pdfinvoice.php so it thinks it's being hacked and bounces you to account_history, as it should.

 

To fix this,

 

EDIT checkout_process.php

 

FIND

 

$_GET['order_id'] = $insert_id;

 

and change to:

 

$HTTP_GET_VARS['order_id'] = $insert_id;

 

This should 'GET' you (c**p pun), up and running!

 

Sincere apologies. This is why I ask for people's PHP versions as many are making the move to PHP5 and unpredictable behaviours like this are happening.

@KJ This is your problem too! Sorry ....

 

Cheers

 

Chris

 

 

Thanks a million Chris!

 

Works nicely :thumbsup:

Link to comment
Share on other sites

Chris,

 

Changed as said above. Now in a test order instead of going to the checkout_success I get the old white page syndrome. In the browser address bar it still says .../checkout_process.php

 

Were getting closer, glad to hear others are up and running however!

KJ

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Hi Chris,

 

I was wondering how easy it would be/if you had any experience of/ adding a barcode of the order number under the order number. Is it just a case of putting a barcode font in the folder and calling that in the code?

 

Regards

 

Dave

Link to comment
Share on other sites

Chris,

 

Changed as said above. Now in a test order instead of going to the checkout_success I get the old white page syndrome. In the browser address bar it still says .../checkout_process.php

 

Were getting closer, glad to hear others are up and running however!

KJ

 

 

Hi KJ,

 

If you turn on error reporting, do you get any generated errors that could help?

 

Cheers

 

Chris

Edited by chris23

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

I was wondering how easy it would be/if you had any experience of/ adding a barcode of the order number under the order number.

 

Hi Dave,

 

No experience but it's something I was asked about for a bookshop who wanted ISBN (EAN-13) barcodes putting on PDFs. This got shelved.

 

Is it just a case of putting a barcode font in the folder and calling that in the code?

 

There appear to be two ways. You can get a 3of9 bacode font here - but I have no idea what a 3of9 barcode is but the web page shows an example of generating 12345 so for an order number this would be fine. Its install looks very easy though!

 

The second method is to generate the barcode as an image using PHP and GD. FPDF has an add on which will import the generated barcode image, from memory, into the PDF. This is probably your only option for a full EAN-13 barcode

 

I would have a look at the first and let me know how you get on.

 

BTW, getting any sleep? :D

 

Regards

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

It's here at last - PDF Packing Slip. Download from contribution area.

 

About

-----

 

This contribution is an ADD-ON to PDF Customer Invoice to allow the the generation of a PDF Packing Slip. A sample PDF is included.

 

 

Pre-requisites

--------------

 

As this is an ADD-ON to PDF Customer Invoice and not a standalone contribution, you MUST have a fully working version of PDF Customer Invoice installed.

 

 

Features

--------

 

i) PDF Packing Slip carries over the colour, graphics and font scheme from the configured PDF Invoice for a consistent look and feel.

ii) Packing Slip incorporates:

 

a) Order number

b ) Customer reference

c) Date of order

d) Total order weight

e) Total order lines

f) Total order items

h) Shipping method

i) Per item weight

j) "Picked by" and "Checked by" fields

k) Latest 3 order comment, if set, are displayed in a "Comments" box. If no comments are set, you can use this box for scribbled notes!

 

Enjoy,

 

Chris

Please use forum for support rather than PM - PMs unrelated to my contributions will be ignored.

Google Site Search is your friend

My contributions: Tracking Module | PDF Customer Invoice | Subcategory textboxes

Link to comment
Share on other sites

Hi Chris,

 

Firstly, Fantastic Mod. Love it! Easy to modify too.

 

A quick question, any plans for a batch print option - using FPDF in the future?

 

Thanks for all your hard work and continued support on this mod.

 

Jodes

Link to comment
Share on other sites

Hi Chris,

 

thanks for this contrib and your help so far to make it work. I now switched my shop to use ssl (didn't get the admin part to work yet, but a least the public part works), but now the links for the pdf invoice from the customers account history don't work any more.

My http server is shop.pipeloops.com, the https server is sssl.kundenserver.de/shop.pipeloops.com (guess you know that's 1und1?). The link properties show

https://ssl.kundenserver.de/shop.pipeloops.com//pdfinvoice.php?order_id=87&osCsid=986e4610ca58f9955e0fa8d54fafbf56

. When I click the link, I get "Internet explorer caanot download pdfinvoice.php from sssl.kundenserver.de".

Any idea?

 

Best regards

Reiner

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.

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...