Skip to content
Advertisement

How to clear specific billing field value from WooCommerce checkout

I am trying to clear the billing_po_no field value from my WooCommerce checkout billing Form, by adding the following code into my functions.php file:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    $fields['billing']['billing_po_no'] = '';

    return $fields;
}

But it does not appear to be working. Can someone point me in the right direction?

Advertisement

Answer

Try the following instead:

add_filter( 'woocommerce_checkout_get_value' , 'clear_specific_checkout_field' , 10, 2 );
function clear_specific_checkout_field( $value, $input ){
    if( $input === 'billing_po_no' )
        $value = '';
    
    return $value;
}

Code goes in functions.php file of the active child theme (or active theme). It should works.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement