In Woocommerce i am trying to clear the checkout fields. so when a user that has ordered something before, and is now ordering something again, he/she will have to write in all
There is some arguments errors in your woocommerce_checkout_get_value
hooked function.
There is in fact 2 arguments:
$value
argument that is returned as it is a filter hook,$imput
argument that you can use to target any checkout field.So in your case you will use the $imput
argument, to avoid your custom VAT checkout field to be emptied. In the code below, you will need to replace vat_number
by the correct field name
attribute that is set in your custom VAT checkout field:
add_filter( 'woocommerce_checkout_get_value' , 'clear_checkout_fields' , 10, 2 );
function clear_checkout_fields( $value, $input ){
if( $input != 'vat_number' )
$value = '';
return $value;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.