Magento 1.8 – How to Display Only One State in Shipping and Billing

billingcheckoutmagento-1.8regionsstate

I am developing an application where the customer is in Canada and the state Quebec only (no other states of Canada).

I wanted to make the customer choose only Quebec state and always Quebec only.
I googled lot for this to hide other states in the select box or to get only Quebec state. I am not getting where to change the code.

I checked if there's JavaScript code to take the role to display and hide the tabs in checkout. Where do I need to hide the other states or select only the Quebec state Id from database?

How can I restrict the customer to select only one Quebec state, only. Already Canada is the only country in the country selection.

Best Answer

I got the answer, Thanks Pradeepsanku,

jQuery('#billing\\:country_id').val('CA'); // CA stands for the Canada
jQuery('#billing\\:country_id').prop('disabled','disabled');

jQuery('#billing\\:region_id').val(76); // 76 stands for the Quebec
jQuery('#billing\\:region_id').prop('disabled','disabled');

I changed the code form

jQuery('#billing\\:region_id').prop('disabled','disabled');
jQuery('#billing\\:country_id').prop('disabled','disabled');

To

jQuery('#billing\\:region_id').attr("readonly",true);
jQuery('#billing\\:country_id').attr("readonly",true);

I come to know that what is the diff between .attr() and .prop(). from here

Difference between .attr() and .prop()

Thank you,