EU/UK VAT Manager field not loading default value from user meta

I was able to fix it myself in the end, using woocommerce_form_field_args filter :


add_filter( 'woocommerce_form_field_args', 'belair_vat_woocommerce_form_field_args', 10, 3 );
function belair_vat_woocommerce_form_field_args( $args, $key, $value ) {
	
    if ( $key == 'billing_eu_vat_number' ) {
		$user_id = get_current_user_id();
		if($user_id){
			$ws_vat_no = get_user_meta( $user_id, 'wwlc_cf_no_tva', true );
			$eu_vat_no = get_user_meta( $user_id, 'billing_eu_vat_number', true );
			$uservatno = $eu_vat_no ? $eu_vat_no : $ws_vat_no ;
		}
		if($uservatno){
		  $args['default'] =  $uservatno; 		
		}
    }
	
    return $args;
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer