Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Default Country in create_account


Guest

Recommended Posts

Posted

I wanted a default country to be displayed in the create account form, so this is what I have done to make United Kingdom a default country:

echo tep_get_country_list('country', '222') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>

The trouble here is that, for obvious reasons, if the customer chooses e.g. United States and there is an error in his form, the Country field gets re-set back to the default country on reload.

How do I make the Country dropdown display a default country and make any other country, if selected, stay there on page reload in case of an error in the form?

Posted
I wanted a default country to be displayed in the create account form, so this is what I have done to make United Kingdom a default country:

echo tep_get_country_list('country', '222') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>

The trouble here is that, for obvious reasons, if the customer chooses e.g. United States and there is an error in his form, the Country field gets re-set back to the default country on reload.

How do I make the Country dropdown display a default country and make any other country, if selected, stay there on page reload in case of an error in the form?

How about looking if $country is set (derived from $HTTP_POST_VARS['country']):

				<td class="main"><?php echo ENTRY_COUNTRY; ?></td>
<?php if (isset($country)) {
 $select_country = (int)$country;
} else {
 $select_country = 222;
}
?>
			<td class="main"><?php echo tep_get_country_list('country', $select_country) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

Posted

Many many thanks Jan! I knew it was simple I just couldn't work it out and I thought of everything else but isset().

:thumbsup:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...