• Resolved TheBusinessCat

    (@thebusinesscat)


    I am using the classic WordPress editor for my checkout page and have added the [woocommerce_checkout] shortcode in the classis editor. I have to do it this way as the Courier Company plugin I am using has issues when using the Gutenburg Block Editor or my theme which is Divi.

    All the fields show as required, except the phone number field which is optional. How can I make this a required field?

    I have read in other posts that this can be set in the theme customizer, but I can no longer access the checkout page from the Customizer, so that is not an option.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Reynier (a11n)

    (@reynierc)

    Hi @thebusinesscat

    Thanks for reaching out! I understand that you’re using Divi and would like to set the phone filed as a required. To make that happen, you can add this bit of code to your theme’s/child theme’s functions.php file.

    Or to better organize your code snippets, I would recommend using a plugin like code snippets or something similar to easily manage them through the dashboard.

    add_filter( 'woocommerce_billing_fields', 'wc_make_phone_field_required' );
    function wc_make_phone_field_required( $fields ) {
    $fields['billing_phone']['required'] = true;
    return $fields;
    }

    Let me know if it works!

    Thread Starter TheBusinessCat

    (@thebusinesscat)

    Hi @reynierc

    Thank you for posting this message. I added your code in the functions.php file of the child theme, but unfortunately, that code did not work.

    Here is a link to the website if it will assist you better:

    https://stationarystylist.co.za/

    Thank you

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @thebusinesscat,

    To clarify, the child theme must be activated for the code to function. However, if you prefer not to activate the child theme, you can use a code snippet plugin, such as Code Snippets, as previously mentioned.

    Thread Starter TheBusinessCat

    (@thebusinesscat)

    Hi @mosesmedh

    Thank you for your message.

    I confirm that the child theme is activated and still does not make the phone field required.

    Thank you.

    Plugin Support Mahfuzur Rahman(woo-hc)

    (@mahfuzurwp)

    Hi @thebusinesscat,

    Thank you for confirming that the child theme is activated. I’ve tested the code on my test site, and it is working as expected. However, custom code is outside the scope of our support, so if the issue persists, I recommend consulting a developer who can assist with further troubleshooting.

    To simplify adding custom code, you can use a plugin like Code Snippets. This ensures your code is applied correctly without modifying theme files directly. Once you’ve added the code using the plugin, please test it again.

    Thanks for understanding!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.