WordPress.org

Forums

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

  1. ferdiax
    Member
    Posted 8 months 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 8 months ago #

  3. magdor
    Member
    Posted 7 months 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 7 months ago #

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

  5. magdor
    Member
    Posted 7 months 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 7 months ago #

    hmmm...Try this:

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

    Copy and paste mine exactly.

  7. magdor
    Member
    Posted 7 months ago #

    Did as advised but still the same result.

  8. magdor
    Member
    Posted 7 months 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 7 months ago #

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

  10. magdor
    Member
    Posted 7 months 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 2 days 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

Reply

You must log in to post.

About this Plugin

About this Topic