Customizing Checkout page, remove State field

This topic has 3 replies, 2 voices, and was last updated 1 years, 8 months ago ago by creativesite

  • Avatar: Barbara
    creativesite
    Participant
    April 18, 2023 at 19:43

    I use an extra plugin, Hucommerce to customize the Checkout page,
    (to remove “State” as we don’t really use it) and the theme probably overwrites that customizing plugin.
    How can I remove “State field”?

    2 Answers
    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    April 19, 2023 at 08:52

    Hello, @creativesite,

    If you are using a plugin like Hucommerce to customize the checkout page in WooCommerce, and your theme is overwriting the customization, you can use some custom code to remove the state field from the checkout page. Here’s how:

    1. Log in to your WordPress dashboard and navigate to Appearance > Theme Editor.

    2. In the right-hand pane, find the “functions.php” file for your child theme.

    3. Add the following code at the end of the file:

    add_filter( 'woocommerce_checkout_fields' , 'remove_state_checkout_fields' );
    
    function remove_state_checkout_fields( $fields ) {
        unset($fields['billing']['billing_state']); // Remove state field from billing section
        unset($fields['shipping']['shipping_state']); // Remove state field from shipping section
        return $fields;
    }

    This code uses a filter to modify the WooCommerce checkout fields and removes the state fields from both the billing and shipping sections.

    Save the changes to the “functions.php” file.

    Test the checkout page to ensure that the state field has been removed.

    Best Regards,
    8Theme’s Team

    Avatar: Barbara
    creativesite
    Participant
    April 19, 2023 at 12:40

    Hi Tony,

    thank you very much!

  • Viewing 3 results - 1 through 3 (of 3 total)

The issue related to '‘Customizing Checkout page, remove State field’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.