0

I am trying to change the Tax label on the cart, checkout order-review and email.

I have tried to create a function with 'woocommerce_get_order_item_totals' and also with 'woocommerce_get_formatted_order_total' No luck. It either remove all or adds a new line but changing the $tax_totals[ $code ]->label

I have a checkbox which gives customers to possibility to apply Tax-exempt for the order. This is all working very good. If selected it will set TAX Amount to 0.00 but the label keeps on VAT or TAX or BTW (Dutch label) I added zero-rates in the backend, Phrase matches used to identify VAT (VAT, V.A.T, IVA, I.V.A., Value Added Tax, TVA, T.V.A., BTW, B.T.W., Tax Exempt, vrijgesteld van BTW) I added zero-rate by country code GB Tax Exempt (0%) NL vrijgesteld van BTW (0%)

And still it shows on the cart, checkout, order-review and email as VAT or(BTW) whatever the country is.

This is what I want to change

Jean Paul
  • 21
  • 3
  • I forgot to mention that this is about VAT relief for disabled people, that is the reason I need it to say "VAT-exempt" and not "VAT" € 0.00 Is for tax reason and to avoid problems later on – Jean Paul Jun 16 '19 at 12:33

1 Answers1

0

I have been looking already for days to find a working solution with no luck. But I found a solution just now, not sure if it is a hack or good coding but it works for me. I have this code inside my function.

add_action( woocommerce_checkout_update_order_review','taxexempt_checkout_based_on_checkbox');
function taxexempt_checkout_based_on_checkbox( $post_data) {
global $woocommerce;    
$woocommerce->customer->set_is_vat_exempt( false );
parse_str($post_data);

if ( $billing_taxexempt === '1' && $billing_confirmed === '1' && 
!empty($billing_signature) && ! empty($billing_declaration)){
    $woocommerce->customer->set_is_vat_exempt( true );  

 } 
 }

This will apply the tax-exempt to the order. I added a filter to this just below ....set_is_vat_exempt( true )..

add_filter( 'woocommerce_countries_tax_or_vat', function () { return __( 'Tax Exempt', 'woocommerce' ); }); 

And I added a function I found //Change "Billing Details" text to "Shipping Details" on Woocommerce checkout page

I changed it a little bit but it works for me.

function wc_change_field_strings( $translated_text, $text, $domain ) {
$language = get_locale();
$domain = 'woocommerce';
if($language == 'en_GB' ){
    switch ( $translated_text ) {
    case 'Tax Exempt' :
        $translated_text = __( 'Tax Exempt', $domain );
        break;
}
return $translated_text;
}

if($language == 'nl_NL' ){
    switch ( $translated_text ) {
    case 'Tax Exempt' :
        $translated_text = __( 'vrijgesteld van BTW', $domain);
        break;
}
return $translated_text;
}
}
add_filter( 'gettext', 'wc_change_field_strings', 20, 3 );

Have to add the default case, will do later but it works for, this solution. Maybe it will work for somebody else or if you have a better solution, let me know.

And the result looks like this.

Jean Paul
  • 21
  • 3