• Resolved Angelo Mosca

    (@moscangelo)


    Hello there!

    From what I understand, billing_phone is required by default in Woocommerce 3.5.7. Yet, it is currently optional (and always has been from what I can recall). I’ve been trying to make it a required field, injecting the snipped below (taken from https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/) in functions.php:

    add_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 );
    function wc_npr_filter_phone( $address_fields ) {
      $address_fields['billing_phone']['required'] = true;
      return $address_fields;
    }

    But this code isn’t working either: the field remains optional. I’ve already done something similar to add a custom country, and that worked just fine. Does anyone know what’s going on, where the problem is…?

    Worth noting: if you’re going to the link I’m providing, know that it will only show the billing form after you have added a product to your cart.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    Hi @moscangelo,

    If you go to Customize > WooCommerce > Checkout, do you have Phone Field set to required there?

    https://cld.wthms.co/rAK3jy
    Link to image: https://cld.wthms.co/rAK3jy

    If you do and it is still not showing as required, it may be due to a theme or plugin conflict.

    Hope that helps!

    Thread Starter Angelo Mosca

    (@moscangelo)

    Hi @yukikatayama and thank you!

    I checked that field, I changed it to the other two options (Optional & Hidden), published, changed it back and, while it worked for Hidden, still no dice on the required field. It only appears as Optional, regardless of what I do.

    Do you have any tips on how to figure out which plugins/themes/child themes could be causing this issue? Perhaps through Google Chrome’s dev console?

    Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    Hi,

    Thanks for checking that setting.

    > Do you have any tips on how to figure out which plugins/themes/child themes could be causing this issue? Perhaps through Google Chrome’s dev console?

    Since it seems that the phone field is still not showing as required, even when the settings in Customizer is set to required, here’s the steps recommended for theme/plugin conflict testing:

    First, backing up your live site before any testing and updates is highly recommended. If you would prefer not to do testing on your live site, first make a back up of your site, then create a staging site using this plugin WP Staging. This creates a copy of your live site where you can make tests without affecting your live site.

    Temporarily switch your theme to one of our default – Storefront or Twenty Nineteen, then deactivate all plugins except for one – WooCommerce. If it shows correctly, then it’s a theme or plugin conflict. Reactivating each plugin one at a time, then see if the issue pops up again will tell us which plugin is conflicting.

    Plugin Support Mike M. a11n

    (@mikedmoore)

    Automattic Happiness Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    hello friends

    Unfortunately i have the same problem as @moscangelo

    although i’ve changed telephone from optional to required in customize-woocomerce-checkout
    nothing happens.. phone is still optional..
    unfortunately in topic never revealed the solution to @moscangelo problem..

    what is the solution to make phone as a required field?

    please advise..

    Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    Hi @footerakia,

    Please open a new thread so we can take a look. Also, please check to see if the theme/plugin conflict troubleshooting helps at all.

    Thanks,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Phone cannot be set as required’ is closed to new replies.