• Resolved Hasi Weragala

    (@hasinthawk)


    Hello There

    Nice plugin but ran into a problem which i don’t have a clue about.

    I’ve set the state (‘billing_state’) as a required field for the checkout form. But alas It is shown as optional in the form.

    settings : https://imgur.com/a/YXpnlhN
    form : https://imgur.com/2X3Iks3

    I have also included the below function in the functions.php to make it required but no avail.

    `add_filter(‘woocommerce_billing_fields’, ‘custom_billing_fields’, 1000, 1);
    add_filter(‘woocommerce_checkout_fields’, ‘custom_billing_fields’, 1000, 1);

    function custom_billing_fields( $fields ) {
    $fields[‘billing’][‘billing_state’][‘required’] = true;

    return $fields;
    }

    Please help.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    The required property of the State field will change according to the country selected.

    You can use the below hook in your child theme’s functions.php to make the state field required for all the country.

    add_filter('thwcfd_address_field_override_required','__return_true');

    We hope this will help ??

    Thank you!

    Thread Starter Hasi Weragala

    (@hasinthawk)

    Works like a charm. Thanks so much mate.

    Plugin Author ThemeHigh

    (@themehigh)

    Great ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Required fields shown as (optional)’ is closed to new replies.