Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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,

share|improve this answer
    
nice great ...... –  Pradeep Sanku Jul 25 at 9:14
    
please mark your answer as accept –  Pradeep Sanku Jul 25 at 9:24

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');
share|improve this answer
    
On which page I need to add this? –  Charlie Jul 25 at 8:35
    
in billing form page and shipping.phtml –  Pradeep Sanku Jul 25 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 at 8:50
    
Thank You for your response, I got answer, –  Charlie Jul 25 at 9:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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