Hi @janvanarkel,
From what I understand about WooCommerce, I don’t think this will be possible. If you disable the taxes, then there will be no taxes in the order back-end, meaning no tax information available for our plugin to grab.
I think the more likely solution would be to enable taxes for everyone, then use some snippet to hide them for everyone, except if the company field is present.
The snippet would then look something like this:
add_filter( 'wpo_wcpdf_woocommerce_totals', 'wpo_wcpdf_custom_totals', 10, 3 );
function wpo_wcpdf_custom_totals ($totals, $order, $document_type) {
// grab the company field
$billing_company = $order->get_billing_company();
// if there is no company, hide various taxes
if ( $billing_company == '' || ctype_space($billing_company) == true ) {
// hide the tax label AND value to make it disappear
$totals['us-us-1']['label'] = null;
$totals['us-us-1']['value'] = null;
}
// return totals, so they are visible on invoice
return $totals;
}
The only catch is that you have to know the names of all the taxes you don’t want to show. In the example above, I’m hiding the “us-us-1” tax. My recommended way of finding the name: when looking at an invoice, enter “&output=html” at the end of the URL & your invoice will switch to an HTML view. Afterwards, inspect the tax by right-clicking & you’ll see something like this:
If you haven’t worked with action hooks before, check this guide out: https://docs.wpovernight.com/general/how-to-use-filters/
I really hope this helps somewhat!