Support » Plugin: WooCommerce Checkout Manager » ‘State’ type in Additional Area not showing up

  • Hi there,

    I added a State field to my additional area as a required field. It’s not showing up in the checkout, however, when I try to submit payment, it says that I need to fill in state.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I am facing the same issue.

    @becky_wp: Have you resolved the issue?

    I’ve had the same issue – doesn’t appear to check any logic to see if the state is required in certain countries.

    I’ve developed this hook which appears to do the job if you’re interested – goes in your functions.php file:

    add_filter( 'woocommerce_checkout_fields' , function($fields) {
        $WC = WC();
        $WC_Countries = new WC_Countries();
        $states = $WC_Countries->get_states($WC->customer->get_country());
        if($states !== false && !count($states)) {
            $fields['billing']['billing_state']['required'] = false;
        }
        $states = $WC_Countries->get_states($WC->customer->get_shipping_country());
        if($states !== false && !count($states)) {
            $fields['shipping']['shipping_state']['required'] = false;
        }
        return $fields;
    });

    Hope this helps

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘‘State’ type in Additional Area not showing up’ is closed to new replies.