Support » Plugin: Checkout Field Editor (Checkout Manager) for WooCommerce » Hook to remove additional field?

  • Resolved Liam McArthur

    (@liammcarthur)



    Is there a hook I can use to programmatically remove an additional field using a plugin? I’ve tried the following, but no dice:

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    function custom_override_checkout_fields( $fields ) {
    	unset($fields['additional']['sales_person']);
    	return $fields;
    }

    I’d like to be able to add an additional sales person field, but only when the IP address matches our office (so that our staff can see and use the field, but customers cannot).

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    The Hook that you have provided is correct. However, could you please verify whether the section name is “additional”? This is because the woocommerce default section names are billing, shipping, account, order.

    If the above information won’t help, then please provide a higher value for the priority say, 99 for the hook.

    We hope this will help 🙂

    Thank you.

    Liam McArthur

    (@liammcarthur)

    I’ve just tried the following:

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 99 );
    
    function custom_override_checkout_fields( $fields ) {
        var_dump($fields);
    }

    This dumps all billing and shipping data, but it doesn’t contain any fields within additional. Is it possible that add_filter( 'woocommerce_checkout_fields', 'name_here' ); is only able to retrieve WooCommerce core checkout data? The only way I’ve managed to get it working at the minute is to hack checkout-form-designer.php with the following:

    if(!in_array($_SERVER['REMOTE_ADDR'], $allowed_ips)) {
        unset($fields['order']['sales_person']);
    }

    … but that’s the last thing I wanted to do!

    Plugin Author ThemeHigh

    (@themehigh)

    Could you please try again with a higher value 2000 for the hook priority. And with section name “order” instead of “additional”.

    Liam McArthur

    (@liammcarthur)

    Yes! You’re absolutely right, it falls under “order” and setting the value to 2,000 made the additional content show. Many thanks for your help with this!

    • This reply was modified 1 year ago by  Liam McArthur. Reason: marking as resolved
    Plugin Author ThemeHigh

    (@themehigh)

    Glad we are able to help you 🙂

    Thank you and have a great day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hook to remove additional field?’ is closed to new replies.