questions

How to clear specific billing field value from WooCommerce checkout

Rate this post

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?

 

✔️Solution:

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.

Leave a Reply

Your email address will not be published.

Back to top button