Support » Plugin: PDF Invoices & Packing Slips for WooCommerce » How to create additional “Download Invoice(PDF)” buttons

  • Resolved eppu

    (@eppu)


    Hi,

    Nice plugin you have created and I bought the pro version to get WPML support.

    I was wondering how can I create “Download Invoice (PDF)” button to the /checkout/order-received/ -page. So when the purchase is complete the buyer can download the directly from the landing page after purchase.

    Also I would like to add button to the /my-account/view-order/111645/ -page. I would like to able to download the PDF directly from my account -order information page and not just from the orders list.

    Thank you for your time

    • This topic was modified 5 years ago by eppu.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! Here’s a link to the documentation page that describes how to add the download PDF button on the thank you page:
    https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/download-link-on-the-thank-you-page/
    To make it WPML compatible, instead of:

    
    $text .= '<p><a href="'.esc_attr($pdf_url).'">Download a printable invoice / payment confirmation (PDF format)</a></p>';
    

    use:

    
    $text .= sprintf( '<p><a href="%s">%s</a></p>', esc_attr($pdf_url), __( 'Download Invoice (PDF)', 'woocommerce-pdf-invoices-packing-slips' ) );
    

    Adding the button to the View Order page is a bit more limited, because by default WooCommerce only has one action here (your theme may have more, but you’d have to check for yourself): woocommerce_view_order
    This is at the very bottom of the page…

    Here’s an example that uses this action:

    
    add_action( 'woocommerce_view_order', 'woocommerce_view_order_pdf_button', 10, 1 );
    function woocommerce_view_order_pdf_button( $order_id ) {
        $pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order_id . '&my-account'), 'generate_wpo_wcpdf' );
        printf( '<p><a href="%s">%s</a></p>', esc_attr($pdf_url), __( 'Download Invoice (PDF)', 'woocommerce-pdf-invoices-packing-slips' ) );
    }
    

    Hope that helps!

    if you need more help with this, don’t hesitate to send us an email at support@wpovernight.com – wordpress.org does not allow us to provide support for our premium products via these forums.

    Ewout

    Thread Starter eppu

    (@eppu)

    Thank you,

    I will try this out today.

    • This reply was modified 5 years ago by eppu.
    Thread Starter eppu

    (@eppu)

    Thank you it worked wonderfully.

    Plugin Contributor Ewout

    (@pomegranate)

    Fantastic, very glad to hear that 🙂

    Have a great week!
    Ewout

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to create additional “Download Invoice(PDF)” buttons’ is closed to new replies.