Search code examples
wordpresswoocommercehook-woocommerce

State isn't show in shipping to address in cart page and selected state in are not checked in checkout page or display order received / thank you page


Due to base country and billing or shipping country are same, country aren't show in cart page shipping to area and order received / thank you page, then I apply this filter to show country.

add_filter( 'woocommerce_formatted_address_force_country_display', '__return_true' );

and now country is visible but how to display state like that.

enter image description here

And the other problem I selected "Burstadt" as a state here but in checkout page Billing address always selected in "Lampertheim" but shipping address are selected the right state.

enter image description here

Because of these two problems order received / thank you page aren't also display the state area. How to solve it.

enter image description here


Solution

  • As your base country is Germany(guessing from the images), the default behaviour for the formatted addresses is to not show state. If you want to change that check the hook woocommerce_localisation_address_formats and return "{company}\n{name}\n{address_1}\n{address_2}\n{city} {postcode}\n{state}, {country}" for DE. See further details here

    I believe this should solve it for all the cases you have.

    As for why your billing address state isn't showing correctly. You probably are a logged in user and probably used that state previously so it is saved into your account/profile. You can change that information directly from your account.