• Resolved thisisbbc

    (@thisisbbc)


    Hey there,

    Really nice plugin you’ve put together. Can’t wait to explore it a little bit more.

    One function that’s missing and that has not been covered in the FAQ is to display the “Download Invoice” button in the View Order page, instead of the My Account page. Having a button with the list of orders makes the UI quite heavy and we’d like to keep it clean.

    It’s probably not much more complicated than to add the button on the thank-you page, probably just using a different hook.

    I’d appreciate if you could put us on the right path!

    Thank you for your help.

    Regards,
    Bastien

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Bastien,
    There’s only one hook on the view order page, woocommerce_view_order: https://github.com/woocommerce/woocommerce/blob/2.6.8/templates/myaccount/view-order.php#L55

    
    add_filter('woocommerce_view_order', 'woocommerce_view_order_pdf_invoice', 9, 2);
    function woocommerce_view_order_pdf_invoice( $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' );
        echo '<p><a href="'.esc_attr($pdf_url).'" class="button">Download PDF Invoice</a></p>';
    }
    

    The order details table is hooked to that same action with priority 10, so if you want to print a link above it you use 9 (as in the example), to print it below, use 11.

    Hope that helps!

    Thread Starter thisisbbc

    (@thisisbbc)

    Working like a charm!

    Thank you a lot for the quick reply Ewout.

    Cheers,
    Bastien

    Plugin Contributor Ewout

    (@pomegranate)

    You’re welcome, have a fantastic day! If you can spare a minute, please leave a review!

    Ewout

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Download Invoice from view-order page’ is closed to new replies.