Plugin Contributor
dwpriv
(@dwpriv)
You can do this with a custom snippet. Give this one a try
/**
* PDF Invoices & Packing Slips for WooCommerce:
* Show a Tax row in totals' area, even if the order taxes are empty (blank or 0)
*/
add_filter( 'wpo_wcpdf_woocommerce_totals', function( $totals, $order, $document_type ) {
if ( empty( $order->get_total_tax() ) ) {
$totals['tax']['label'] = __( 'Tax', 'woocommerce' );
$totals['tax']['value'] = wc_price( 0 );
}
return $totals;
}, 10, 3 );
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use code snippets
Hi,
Your code is great! The only thing is that it is automatically translated as “Impuesto” (in Spanish) and appears below the total. I would like it to be displayed before the total so that the invoice is correct, and to be called “TAX” so that it is 100% valid and legal.
Could you help me?
Thank you very much
Plugin Contributor
dwpriv
(@dwpriv)
You can try replacing that snippet with this one
add_filter( 'wpo_wcpdf_woocommerce_totals', function( $totals_data, $order, $document ) {
if ( ! empty( $order ) && $document == 'invoice' ) {
if ( empty( $order->get_tax_totals() ) ) {
$no_vat[] = array(
'tax' => '',
'type' => 'total',
'label' => 'TAX',
'value' => sprintf('<span class="custom-tax">%s</span>', wc_price( $order->get_tax_totals() ) ),
'class' => 'total',
);
$totals_data = $no_vat + $totals_data;
}
}
return $totals_data;
}, 10, 3 );
It’s perfect now!
Thank you so much for your help 🙂