2

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.

3

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,

1

you can use the following code

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');
  • On which page I need to add this? – Charlie Jul 25 '14 at 8:35
  • in billing form page and shipping.phtml – Pradeep Sanku Jul 25 '14 at 8:36
  • Its working as I need, but when I click on continue it show "Please Enter Country" in alert Box. so I removed the disable code, Then again alert message for state as "Please Enter State". – Charlie Jul 25 '14 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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