WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Removing fields in Checkout page (11 posts)

  1. ferdiax
    Member
    Posted 1 year ago #

    I would like to remove 2 fields from the checkout page. The fields being 'address 2' and 'Telephone' is this possible and how do i go about this.
    Thanks

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

  3. magdor
    Member
    Posted 1 year ago #

    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)

  4. royho
    Member
    Posted 1 year ago #

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

  5. magdor
    Member
    Posted 1 year ago #

    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;
    }
  6. royho
    Member
    Posted 1 year ago #

    hmmm...Try this:

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

    Copy and paste mine exactly.

  7. magdor
    Member
    Posted 1 year ago #

    Did as advised but still the same result.

  8. magdor
    Member
    Posted 1 year ago #

    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.

  9. royho
    Member
    Posted 1 year ago #

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

  10. magdor
    Member
    Posted 1 year ago #

    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.

  11. miketopher
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic