If this is your first visit, check our documentation. To post, register or login.
Forums / Managing Customers and Orders / Custom Customer Downloadable PDF Invoice generated externally

Custom Customer Downloadable PDF Invoice generated externally

Started by mickymix on 27 Feb 2013, 10:38 AM · Views: 1,025

Results 1 to 3 of 3
27 Feb 2013, 10:38 AM
#1
mickymix avatar

mickymix

New Zenner

Join Date:
Jun 2012
Posts:
41
Plugin Contributions:
0

Custom Customer Downloadable PDF Invoice generated externally

I've been searching quite a while and a possible solution might be behind the corner, but either it's me that cannot find it, either it's just hidden a little bit more than expected...

I'm in the need of giving my customers the chance to be able to download their PDF invoices from the order history page.

The "special" need is that this PDF document is not actually generated from ZenCart, but from another system in the company and I cannot avoid this (there are some legal restriction I won't bother you with).

It won't be a problem to upload such documents to the web in a special folder, and they might be named as needed (obviously either the Customer ID and/or the Invoice number can be part of the name: i.e. "IIIII_NNNNN.pdf").

The need would be to make this document accessible from every single customer upon request.

I thought of making this a download item to be added manually to each order after creation (at least at beginning, until a specific code would be created), but this would involve creating a single article for any single order (crazy!).

PDF Invoice 3, which I looked at (but not installed yet) seems giving this chance (and I'll probably look at the code for the areas I would need only), but the document is generated by this addon, not just "added" from an external source.

Does anyone has any hint ?
I'm not a programmer, but I can use "cut & paste" quite good (I can read the code, even if not write it... :cool:)

Thank you for ANY suggestion.

mickymix

ABANDONED PROJECT

28 Feb 2013, 11:53 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Custom Customer Downloadable PDF Invoice generated externally

I would encourage you to name the files with the date+time+custnum+ordernum. Leaving out the date+time makes the filenames WAY too easy to guess and steal information that ought to be private. At least the date+time adds some more complexity to it.

That said, it would be better to not have the files in a publicly accessible download folder, but to instead serve the file dynamically on-demand. Much more secure that way. For that approach, I'd put the files into a folder above your web-root and use a download script to read and serve the file when requested, and only serve files that suit the currently-authenticated customer, rejecting any requests for content that belongs to another customer, etc.

Since you said you wanted this to be on the order-history page, it's basically a "new feature", and will require you to add custom code to handle it:

  • system looks for a related .pdf for that order, If present, gives a download link. If not, display some "pending" icon or such.
  • user clicks the download link, and system verifies that the parameters submitted by the "click" match the customer who's logged in, and that the order number exists for that customer.
  • system finds the pdf from the correct folder and reads the file contents and streams it out to the customer's browser, ideally into a new window so the content doesn't get confused with other HTML

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Mar 2013, 11:44 AM
#3
mickymix avatar

mickymix

New Zenner

Join Date:
Jun 2012
Posts:
41
Plugin Contributions:
0

Re: Custom Customer Downloadable PDF Invoice generated externally

Thank you DrByte.

Your precious answer confirm me that, at least, I've been able to explain my idea correctly.

And yes, I now know this is something which has never been investigated yet, or so requested, to have someone develop for the community. :-(

I hoped this, for a while...

As I said anyway, I'm not a coder, so I'll look around for someone to do this for me...

All your considerations were already present in my mind, beside the "new window" one, which I find very useful.

Thank you again.

If some coder is just crossing his (her) fingers and would like to show his own capabilities, well, this might be a good chance... :-D JJ

ABANDONED PROJECT