0

Magento 2.4.6-p3

I am hiding the state option in checkout and for those cases where the customer does not have to select a state, the state is always set to "Texas".

I did not find a setting where some default value is set to Texas. What could be the reason?

Thanks

1
  • How you hide that options? Before hiding what option show on the list? Commented Sep 17 at 4:13

1 Answer 1

0

Magento 2 does not provide a direct option to set a default state in the Admin panel. We have to set it programmatically. The easiest way to set the default state value is from the js script below:

jQuery("select[name='region_id'] option[value='57']").prop('selected', true);

This will set the default state to Texas where 57 is the state option value of Texas. You can include this script in your js file and load it on checkout page. This is the hardcoded way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.