Remove phone from billing/shipping fields everywhere in Woocommerce?

前端 未结 1 889
南旧
南旧 2021-01-20 02:42

I don\'t need to collect customer phone numbers in woocommerce so I\'ve used the following code to remove them from the checkout process:

add_filter( \'wooco         


        
相关标签:
1条回答
  • 2021-01-20 02:50

    Here is the complete way to do it in account and checkout pages (for both pages):

    // Remove billing phone (and set email field class to wide)
    add_filter( 'woocommerce_billing_fields', 'remove_billing_phone_field', 20, 1 );
    function remove_billing_phone_field($fields) {
        $fields ['billing_phone']['required'] = false; // To be sure "NOT required"
    
        $fields['billing_email']['class'] = array('form-row-wide'); // Make the field wide
    
        unset( $fields ['billing_phone'] ); // Remove billing phone field
        return $fields;
    }
    
    // Remove shipping phone (optional)
    add_filter( 'woocommerce_shipping_fields', 'remove_shipping_phone_field', 20, 1 );
    function remove_shipping_phone_field($fields) {
        $fields ['shipping_phone']['required'] = false; // To be sure "NOT required"
    
        unset( $fields ['shipping_phone'] ); // Remove shipping phone field
        return $fields;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works

    Normally shipping email and phone fields doesn't exist by default in WooCommmerce

    0 讨论(0)
提交回复
热议问题