Pakistan Web Development Consultant Adeel Sarfraz is a consultant based in Pakistan giving out tips, tricks and code samples

28Sep/090

How to display state/province dropdown instead of input box in Zencart

In the default Zencart template the customer is asked for his State/Province by entering the value into the text box. However, mistakes can happen at any time and the customer may mistype the name. Zencart checks the name against the zones input in the admin panel. If it does not match Zencart flags an error and the customer has to retype it thus causing frustration which may lead to lost sales.

The way to go is display the State/Province in a drop down so the customer has to just select the name in the drop down and continue with the checkout process.

To do that you need to open the includes/modules/create_account.php file and go to the end of the file where you will see the following line


$flag_show_pulldown_states = ((($process == true || $entry_state_has_zones == true) && $zone_name == '') || ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true' || $error_state_input) ? true : false;

This is code which determines whether or not to show the drop down. Now you can either confirm that all the conditions are true or take the practical (aka shorter) route and comment the line and add the following code on the next line. So the above line would look like


// $flag_show_pulldown_states = ((($process == true || $entry_state_has_zones == true) && $zone_name == '') || ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true' || $error_state_input) ? true : false;

$flag_show_pulldown_states = true;

Now if you run the register page you can see that the dropdown will show.

Hope the above helped.

Filed under: Uncategorized No Comments