Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor royho

    (@royho)

    I followed the instructions per the given link and removed the billing_phone field from the checkout page. But when click the checkout button I am greeted with the following message:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘custom_override_checkout_fields’ was given in /home/content/xxxxxxxxx/sitenamehere/wp-includes/plugin.php on line 170

    Warning: Invalid argument supplied for foreach() in /home/content/xxxxxxxxx/sitenamehere/wp-content/plugins/woocommerce/classes/class-wc-checkout.php on line 157

    This error does not show up with the phone field back in. What do the error messages mean? And how to fix it?

    Here the test page with the buy button at the end of the page:

    (Site in dutch, but you can safely ignore that)

    Plugin Contributor royho

    (@royho)

    Hard to help without seeing your code…try pasting it here..

    Sorry about that:

    /* WooCommerce: Remove phone number on checkout page. */
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

    and

    function custom_override_checkout_fields( $fields ) {
         unset($fields['billing']['billing_phone']);
         return $fields;
    }
    Plugin Contributor royho

    (@royho)

    hmmm…Try this:

    add_filter( 'woocommerce_checkout_fields', 'custom_override_checkout_fields', 10, 1 );
    

    Copy and paste mine exactly.

    Did as advised but still the same result.

    Minor progress. Now the field is removed from the checkout page but when going for placing the order, the error message shows up that this is a required field even though it is not visible anymore.

    Plugin Contributor royho

    (@royho)

    You said “same result”. Does that mean with my code, you’re still getting the PHP error?

    Royho,

    My bad. This strange behaviour was a result of a missing } in one of the previously defined functions. So all is well again. Thank you for your support and patience.

    How can I add multiple fields to remove, to that one bit of code?

    function custom_override_checkout_fields( $fields ) {
    unset($fields[‘billing’][‘billing_phone’]);
    return $fields;
    }

    I also want to remove the entire address fields as my products are all free

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Removing fields in Checkout page’ is closed to new replies.