Home Forums WoodMart – Premium Template Checkout State Select Field Customization

This topic contains 4 replies, has 2 voices, and was last updated by Artem Temos Artem Temos 1 month, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #164764

    Coffeecream
    Customer

    Hello,

    I’m trying to customize the checkout State select field.

    1) Change field label to “Areas”
    2) Change placeholder
    3) Make field mandatory
    4) Move it right after the country select

    I know how to do all those things in the child theme functions.php. Other field’s customization is working fine.

    But the problem that in the case with this field my code is not working. Or I would say it is working until JS applied. I think it happens because the script you are using to make this State field nicer, but it makes it not customizable…

    What should I do in this situation?

    Following is the code for child theme:

    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
    
        $fields['billing']['billing_state']['label'] = 'Area';
        $fields['billing']['billing_state']['required'] = true;
        $fields['billing']['billing_state']['priority'] = 20;
    
        unset( $fields['billing']['billing_company'] );
        unset( $fields['billing']['billing_postcode'] );
        unset( $fields['billing']['billing_city'] );
    
        unset( $fields['order']['order_comments'] );
    
        return $fields;
    }
    #164781

    Hello,

    Could you please check how it works with some default WordPress theme like twentysixteen to understand is it our theme issue or not? Actually, we don’t use any scripts there and they are just standard WooCommerce fields.

    Regards

    #164786

    Coffeecream
    Customer

    You are right, I see no it behaves the same way with default themes. First, it appears as a usual select in the place where I move it with code and with the “Areas” title, and then JS catches and it moves to default place and uses default title!

    #164793

    Coffeecream
    Customer

    I just used a different filter ‘woocommerce_default_address_fields’ and it worked. Thank you.

    #164799

    Great, we are glad that you sorted it out.

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

The topic ‘Checkout State Select Field Customization’ is closed to new replies.