• Resolved Drivingralle

    (@drivingralle)


    Hey!

    As I’m building a new shop for a client for the german market I’m using the new checkout block. Inside the option of that block I found the settings to toggle the company field and more. But the toggle for the state field is missing.

    Inside Germany the state is irrelevant. If anything is interesting it’s the zip code. I know it’s the same for Denmark. Therefore it would be great to be able to hide the state field just like the company field. As the system supports it to be optional, it should also be possible to hide it.

    If plugins/payment gate ways need this field, maybe a filter could be added to enforce the field.

    I guess a nice way would be to add a flag to the translations of WooCommerce to allow the plugin translators to adjust this to their locale.

    Greetings
    derRALF

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @drivingralle

    Unfortunately, the checkout block does not have this feature built-in. However, you can achieve this by using a custom code:

    It would be also great to have you add your ideas as an enhancement request, which is where developers go to look for future plugin features and improvements.

    For reference, this particular forum is meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight.

    Thread Starter Drivingralle

    (@drivingralle)

    Hey!
    I digged a bit more into it.

    Bildschirmfoto 2024 08 06 um 16 01 31

    As soon as I pick a country like Denmark from the drop-down inside the invoice address the state field is hidden. Going back to Germany or the USA the field shows up again. Also the order of the fields change.

    Bildschirmfoto 2024 08 06 um 16 01 40

    Where is this configured?
    Translations? WooCommerce Core?

    Greetings
    derRALF

    @drivingralle That happens because Denmark has no “states” defined in WooCommerce and is set to hide the field on the WooCommerce default locales.

    There is no setting but you can use a filter to hide the state field for Germany:

    add_filter( 'woocommerce_get_country_locale', function( $countries ) {
    $countries['DE']['state']['hidden'] = true;
    return $countries;
    } );

    You can also completely remove the German states if you want:

    add_filter( 'woocommerce_states', function( $states ) {
    $states['DE'] = array();
    return $states;
    } );

    Hey, @drivingralle!

    As explained, this happens because by default the Germany State field is set as optional and for Denmark it is hidden.

    As my colleague suggested, if you wish, you can report it as a enhancement request suggesting to hide it, so our team can take a look at it ??

    Please let us know if there’s anything else we can do to help or if you have any questions.

    Have a wonderful day!

    As my colleague suggested, if you wish, you can report it as a enhancement request suggesting to hide it, so our team can take a look at it ??

    Be aware that changing this will change all the WooCommerce shops in the world, and other people might rely on having the “German state” visible.

    For example for Portugal, the states are not part of WooCommerce and the field is hidden. Most people rely on that but those who want to have our Districts use my plugin to achieve it, which adds the states (Districts actually) and shows the field. In 2021 a user opened an issue suggesting the inclusion of those Districts, which turned into a PR that skipped beta and RC versions, and it potentially broke 4000+ websites (now 5000+) that were relying on the WooCommerce default settings and using my plugin to override them.

    Thread Starter Drivingralle

    (@drivingralle)

    Thanks @webdados for the snippets.

    I’ll look into it. I know that it can break stores. Currently also all german stores “feel” broken, because there is no State information in all kind of addresses we use in every day life. There is even a Norm (DIN 5008) about how to label mail.

    It’s Germany, of course there’s a norm ??

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @drivingralle

    I’m marking this topic as “resolved” due to recent inactivity. Hopefully, you were able to find a solution to your problem! If more assistance is needed, feel free to post back here or open a new topic.

    Thanks!

    Thread Starter Drivingralle

    (@drivingralle)

    The problem is not solved. But it’s a bigger topic that needs to be changed in WooCommerce core in general.

    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello Drivingralle,

    Thank you for your reply

    I suggest you report your query at our Feature Request portal.
    We would love to hear your feedback and improve WooCommerce.

    Have a great day!

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.