Home Forums WoodMart support forum Checkout page Custom shipping states are optional. I need to make it required

Checkout page Custom shipping states are optional. I need to make it required

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #300690

    keplercloud
    Participant

    I added custom states for shipping states.
    In checkout page it state shows as optional. I tried to make it required by using follow code in the functions.php file in my child theme.

    add_filter( 'woocommerce_billing_fields', 'mp_filter_state_billing');
    add_filter( 'woocommerce_shipping_fields', 'mp_filter_state_shipping');
     
    function mp_filter_state_billing( $address_fields ) { 
        $address_fields['billing_state']['required'] = true;
        $address_fields['billing_state']['label'] = 'District';
        return $address_fields;
    }
    function mp_filter_state_shipping( $address_fields ) { 
        $address_fields['shipping_state']['required'] = true;
        $address_fields['shipping_state']['label'] = 'District';
        return $address_fields;
    }

    But it show the correct label for a second and reset back to “State / County (optional)”

    How can I fix this

    #300695

    Hello,

    Thank you very much for choosing our theme and for contacting us.

    Please make the full backup of your site as well as the Theme settings export and check the issue on the Storefront theme to detect if our theme causes the problem. Storefront is a free theme developed by WooСommerce.

    Best Regards

Viewing 2 posts - 1 through 2 (of 2 total)