• Resolved mec022

    (@mec022)


    Hi
    The checkout form for https://gesbo.ch is not working correctly. In Woocommerce Checkout Fields the fields “billing_state” and “shipping_state” are saved as required fields but the output in the cart page shows (optional) instead of an * for required.
    Do you have an idea what goes wrong here?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    These fields are required by default, but you can try this snippet:

    add_filter( 'woocommerce_default_address_fields', 'ywp_customising_checkout_fields', 1000, 1 );
    function ywp_customising_checkout_fields( $address_fields ) {
        $address_fields['state']['required'] = true;
    
        return $address_fields;
    }

    Code goes in function.php file of your active child theme (or active theme). tested and works.

    Good luck

    Thread Starter mec022

    (@mec022)

    Thanks!

    You’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘checkout field displayed (optional) instead of required’ is closed to new replies.