• Resolved roger.manche

    (@rogermanche)


    Hi Ewout,

    I’d would like to use an alternative template for the ‘new order’ email (admin/storemanager only).

    I need some extra information on the invoice the store manager receives as an attachment to the ‘new order’ email. This extra information should not be visible on the customers’ version of the attached pdf invoice.

    Currently I’ve edited my invoice.php template to display this information only when the following condition is true:

    if ( current_user_can( 'shop_manager' ) OR current_user_can( 'administrator' ) ){
    // output extra information for admin & storemanager only
    }

    This works fine for viewing the invoice in the backend however the generated invoice.pdf attachment sent via email to the customer also contains this information.

    Would it be possible to use a different template (for example invoice_admin.php) only for the pdf generated for the ‘new order email’ sent to admin?
    The customer would still receive the regular invoice.pdf (based on the invoice.php template).

    Thanks in advance for your kind assistance.

    Cheers,
    Roger

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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

    Thread Starter roger.manche

    (@rogermanche)

    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

    Thread Starter roger.manche

    (@rogermanche)

    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

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘use alternative invoice.php template for admin & storemanager only’ is closed to new replies.