Download Invoice in My-Account Orders Page

Hi, this topic has already been discussed here:

Good luck! 🙂

Hi Cold @cold2425
I have looked into it and tried already but it breaks down the site. Which is why I opened the topic.

Thanks and Regards

And what exactly is happening? Because literally yesterday I implemented it on my website and everything works.

Dear Cold,
Quoted snippet was for any other page. And I was concerning about for my-account/orders page which is WooCommerce page.
Though I have tried it in different ways already but I am getting ‘critical site’ error.

Regards

Obviously you have to customize it for your site, but the code itself works because I implemented it yesterday. It doesn’t matter where you want to insert it, you just need to correctly pass the order id and user email address that are used in this snippet.

  • This reply was modified 6 minutes ago by Cold.

Well, I was working on the same to modify the code. and now the good news is, I get it solved.

here is the updated snippet that might help the community.

function download_invoice_button( $actions, $order ) {
$actions['download_invoice'] = array(
'url' => wp_nonce_url( home_url( '/?attaching_pdf=1&print_packinglist=true&email=".base64_encode( $order->get_billing_email() )."&post=".base64_encode( $order->get_id() )."&type=download_invoice&user_print=1&wpnonce=".wp_create_nonce( "wf-woocommerce-packing-list' ) ), 'wf-woocommerce-packing-list' ), 'name' => _( 'Download Invoice', 'textdomain' )
);
return $actions;
}
add_filter( 'woocommerce_my_account_my_orders_actions', 'download_invoice_button', 10, 2 );

This code should go into your theme’s function.php file

Thanks and Regards,
Nabeel

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer