• Resolved tobbecokta

    (@tobbecokta)


    Hi,

    I am trying to use below code to hide the shipping email and phone field for logged out users, in the checkout. But the fields are still showing. Got any recommendation for how to hide it?

    	add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    function custom_override_checkout_fields( $fields ) {
        if( !is_user_logged_in() ){
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_vat_number']);
    unset($fields['shipping']['shipping_phone']);
    unset($fields['shipping']['shipping_email']);
        }
        return $fields;
    }
Viewing 1 replies (of 1 total)
  • Plugin Author FAKTOR VIER

    (@faktorvier)

    Hi @tobbecokta

    I just tried your code on our test environment and it seems wo work correctly. Both phone and email fields are missing in the shipping address form if I add this code to our functions.php.

    Are you sure you placed the code in the correct file and that this file is correctly loaded? Also, are you sure you tested it as logged out user? Else you could try to add a higher priority (maybe 99) to the hook, although this should not be necessary:

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 99);

    If all of that is not working, then maybe you have some other hooks or plugins that cause problems.

    But all in all, your code should work perfectly.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide shipping phone and email for logged out users’ is closed to new replies.