Yes it’s possible to add a Download Invoice button next to the “View” button in the WooCommerce My Account → Orders table.
By default, WooCommerce doesn’t generate invoices in PDF. For that, you’ll need an invoice plugin (e.g., WooCommerce PDF Invoices & Packing Slips – the most popular free one). That plugin registers a function to generate/download invoices, and we can hook into it to add a button.
Here’s a general snippet for the free WooCommerce PDF Invoices & Packing Slips plugin:
/**
* Add Download Invoice button next to View button in My Account > Orders
*/
add_filter( 'woocommerce_my_account_my_orders_actions', 'add_invoice_download_button', 10, 2 );
function add_invoice_download_button( $actions, $order ) {
// Make sure WooCommerce PDF Invoices & Packing Slips is active
if ( class_exists( 'WPO_WCPDF' ) ) {
$actions['invoice'] = array(
'url' => wp_nonce_url(
add_query_arg( array(
'pdf_invoice' => 'true',
'order_ids' => $order->get_id(),
), home_url() ),
'generate_wpo_wcpdf'
),
'name' => __( 'Download Invoice', 'woocommerce' ),
);
}
return $actions;
}
And if you want without a plugin, out of the box, WooCommerce does not generate PDF invoices — it only stores order data in the database. A PDF needs to be dynamically created (HTML → PDF), which requires a library like Dompdf, TCPDF, or mPDF. That’s why most people use plugins, because they bundle those libraries and handle formatting.
But yes, it’s possible without a plugin, if you’re okay with some custom coding.
Here’s the flow we’d need:
Create a custom endpoint (like ?download_invoice=ORDER_ID).
Fetch the WooCommerce order data.
Generate a PDF (using PHP library like Dompdf or FPDF).
Stream it as a download.
Add a "Download Invoice" button in the My Account Orders table that points to that endpoint.
Here’s a minimal example using the built-in FPDF library (lightweight but basic formatting):
// Add "Download Invoice" button next to View
add_filter( 'woocommerce_my_account_my_orders_actions', 'custom_add_invoice_button', 10, 2 );
function custom_add_invoice_button( $actions, $order ) {
$actions['invoice'] = array(
'url' => add_query_arg( array(
'download_invoice' => $order->get_id(),
), home_url() ),
'name' => __( 'Download Invoice', 'woocommerce' ),
);
return $actions;
}
// Catch invoice download request
add_action( 'init', 'custom_generate_invoice_pdf' );
function custom_generate_invoice_pdf() {
if ( isset( $_GET['download_invoice'] ) ) {
$order_id = intval( $_GET['download_invoice'] );
$order = wc_get_order( $order_id );
if ( ! $order ) return;
// Load FPDF (must be available in your theme/plugin folder)
require_once get_stylesheet_directory() . '/fpdf/fpdf.php';
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont( 'Arial', 'B', 16 );
$pdf->Cell( 40, 10, 'Invoice for Order #' . $order->get_id() );
$pdf->Ln(20);
$pdf->SetFont( 'Arial', '', 12 );
$pdf->Cell( 40, 10, 'Customer: ' . $order->get_formatted_billing_full_name() );
$pdf->Ln(10);
$pdf->Cell( 40, 10, 'Total: ' . $order->get_formatted_order_total() );
// Output PDF
$pdf->Output( 'D', 'invoice-' . $order->get_id() . '.pdf' );
exit;
}
}
You need to include a PDF library (fpdf.php or dompdf.php) inside your theme or custom plugin folder.
This is a basic invoice. For styling (tables, product list, logo, etc.), you’d need to extend it.
Unlike plugins, this approach doesn’t give you settings or templates — it’s pure code.
Cheers.