“state” field in woocommerce checkout page is not appearing when choosing certain countries like germany, so when the customer clicks place order, and error appears that he needs to put the state, however its not possible to put the state since there is no field for it.
1- if he chooses countries like United Arab Emirates, USA, Canada, etc…, a state field appears and the customer can fill it normally and the payment goes through with no problems.
2- if Germany, or Afghanistan or some different countries are chosen, the “state/county” field disappears, and when the customer clicks “place order” and error appears: “shipping_state post variable not found”.
i’m using paytabs as a payment gateway.
I’m not sure what code to edit, but woocommerce shows “state” fields dynamically based on chosen country.
error appears that the customer needs to put the state, however its not possible to put the state since there is no field for it.
2
Answers
As default woocommerce does not show state field for some countries you can see those countries in class-wc-countries.php
the below code will allow state field for Afghanistan please test and edit to your suiting
The error you are experiencing is the line with the "var_dump", which is outputting all the states information to the screen. Just remove that line and it works perfectly, I just did this on my website with Austria "AT".
For more information, just google "php var_dump" and it tells you what that function does.