Need to Add a default city and state in the checkout page
-
Hi, I am developing a delivery website and I deliver only in one city, so during the checkout I want to add the city and state name by default and not give the user the option to edit it: https://prnt.sc/214teks – check this right now it’s editable
If you check here the country option is set as default – https://prnt.sc/21f6qjh in my checkout flow.I have searched and tried many codes from stack overflow and WooCommerce docs, somewhere I am doing a mistake!
Kindly help me out – share a code that I can add in my functions.php file of my theme editor which will make both the billing and shipping values of city and state as KADAPA and ANDHRA PRADESH respectively!
Currently, I am trying to add this piece of code in my theme editor’s function.php file, but it is not working:
add_filter( 'default_checkout_billing_city', 'change_default_checkout_city' ); add_filter( 'default_checkout_billing_state', 'change_default_checkout_state' ); function change_default_checkout_city() { return 'Kadapa'; // country code } function change_default_checkout_state() { return 'Andhra Pradesh'; // state code }
I will be really grateful!
Site URL: https://expressmeatmart.com/
Xstore Theme version: 8.0.10
WooCommerce version: 5.9.0The page I need help with: [log in to see the link]
- The topic ‘Need to Add a default city and state in the checkout page’ is closed to new replies.