https://woocommerce.com/products/eu-vat-number/
In the documention it mentions things about excluding or including specific countries.
add_filter( 'woocommerce_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' );
function woo_custom_eu_vat_number_country_codes( $vat_countries ) {
$display_vat = array_diff($vat_countries, ['SE', 'GB']); // remove countries in second array
return array_values($display_vat); // reindex array
}
I would like to do the same but then for values of a custom dropdown field. Eg. If private customer, then don't show the VAT Number Field and also not remove the VAT.
How could I achieve this?
Thanks!
I've managed to solve this issue by detaching and prepending the field with jQuery.
if (jQuery('#wc_billing_field_7378 :selected').text() === 'Zakelijk') {
jQuery('.woocommerce-billing-fields__fieldwrapper').prepend(vatfieldprepend);
}
else{
vatfieldprepend = jQuery('#woocommerce_eu_vat_number_field').detach();
}
}).change();