Plugin Contributor
Ewout
(@pomegranate)
Hello Roger,
The PDF generation is separated from the attachment process, so the processes that create the PDF don’t have any information about the email it is attached to.
You can detect if the PDF is requested via the browser, but if I understand your question correctly, you only want to control the attachment?
for the browser request check you can do:
if ( ( current_user_can( 'shop_manager' ) || current_user_can( 'administrator' ) ) && ( !empty($_GET['action']) && $_GET['action'] == 'generate_wpo_wcpdf' ) ){
// output extra information for admin & storemanager only
}
Hope that helps!
Ewout
Hi Ewout,
thanks for your reply.
Yes, you did understand correctly. I would like to control the attachment and send a different version of the invoice (with added information) to the admin only.
Since the PDF generation process doesn’t have any info about the email it is send to, and basically the same generated pdf is sent to both admin and the customer, would it be possible to attach a different pdf to the admin email?
I’d see two possible solutions:
Solution A
Admin receives:
invoice_admin.pdf (based on invoice_admin.php)
Client receives:
invoice.pdf (based on invoice.php)
Solution B
Admin receives:
invoice.pdf (based on invoice.php) – same pdf as sent to the customer
invoice_admin.pdf (based on invoice_admin.php)
Client receives:
invoice.pdf (based on invoice.php)
I hope this clarifies my intentions and maybe you have an action hook for this to generate and attach a second pdf.
Thanks again for your kind assistance.
Roger
Plugin Contributor
Ewout
(@pomegranate)
Hi Roger,
I think the easiest way to accomplish this is with the Professional extension, where you get an additional “Proforma Invoice” document that you could use as the invoice to send to the admin.
We have a new release for the Professional extension coming up that lets you change the document title and filename via the settings too, if you decide to go this route send us an email at [email protected] with your order number or license key and we can send you the beta.
Setting up a completely new document is not a trivial task with a single hook – you have to extend the base document class, define the properties and register it with the plugin so it knows to put the settings/buttons etc.
Ewout
Thanks Ewout!
Sounds like a solution to me 🙂
I just send my purchase details to the support email.
Looking forward to test the beta version.
Thanks!
Roger