Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Set "Default" country for create_acount.php and Address Book


vcoutin@cambridgecollege.edu

Recommended Posts

Posted

Hello,

 

I've been working on putting this store together for a while, and have added several contributions to the application. I'd like to set a default country in the Signup page as well as on the address book so that the states drop down gets populated automatically. I have the Paypal Direct module and other contributions installed on the files "create_account.php" as well as on the "address_book_process.php" so I would have to edit the code by hand.

 

Could someone help me please?

 

Thanks,

 

- vcoutin

Posted

In includes/functions/html_output.php edit the tep_get_country_list function definition to be:

function tep_get_country_list($name, $selected = STORE_COUNTRY, $parameters = '') {

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted
In includes/functions/html_output.php edit the tep_get_country_list function definition to be:

function tep_get_country_list($name, $selected = STORE_COUNTRY, $parameters = '') {

 

---

 

Hey Daemonj,

 

Thanks for replying. I tried the code you've given me in html_output.php and couldn't get it to work. I wodner if I just got the sintax wrong. Here's what I got:

 

 

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = United States, $parameters = '') {
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = tep_get_countries();

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }
?>

 

For some reason it only worked using the country id from the database table, as in

function tep_get_country_list($name, $selected = '223', $parameters = '') {

 

Now, I figured the stinking thing would load the states pull-down menu if I had a country already selected (which we know didn't happen). Do you know how to acomplish this?

 

Thanks again

Posted

 

 

That would work great on a new, clean installation, but I have added so many contributions I couldn't just go ahead and replace all the code just like that. DaemonJ knew how to accomplish this in a really clean way by just editing a line in includes/functions/html_output.php.

 

I wonder if there's something similar that I could do to populate the states pull-down automarically.

 

Thanks

Posted

It was supposed to be:

$selected = STORE_COUNTRY

 

exactly without interpretation.

 

For the States pull down just before the closing ?> before the first bits of HTML you could add:

if ($country = '') {
 $country = STORE_COUNTRY;
}

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

Daemonj,

 

I certainly wish I was as smart as you, or simply that I new my stuff here.

I tried the code

 

if ($country = '') {

 $country = STORE_COUNTRY;

}

 

at the end of includes/functions/html_output.php, right before the php closing ?>

I got no love (and no states pull down) from it.

 

Then I figured oh! it must go in the create_account.php page. again, I placed is before the ?> right before any HTML code, but again, no love.

 

Thanks a lot for your patience and you help. One day I'll know what I'm doing here.

Posted

Please re-read my post. That code goes at the top of the create_account.php file before the *first* ?> tag.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

Allright, this is what I got on create_account.php

 

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

if ($country = '') {

 $country = STORE_COUNTRY;

}


?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>

 

So that's right before the first ?> tag, right?

Yet, it's still not working on Firefox nor IE. I figured maybe the file wasn't uploading correctly, so I saved it as create_account2.php, and still nothing.

 

Would the fact that I have PayPal WPP Modification make a difference at all?

Posted
---

 

Hey Daemonj,

 

Thanks for replying. I tried the code you've given me in html_output.php and couldn't get it to work. I wodner if I just got the sintax wrong. Here's what I got:

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = United States, $parameters = '') {
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = tep_get_countries();

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }
?>

 

For some reason it only worked using the country id from the database table, as in

function tep_get_country_list($name, $selected = '223', $parameters = '') {

 

Now, I figured the stinking thing would load the states pull-down menu if I had a country already selected (which we know didn't happen). Do you know how to acomplish this?

 

Thanks again

 

 

I implemented this same change with no problems. You've typed "United States" were you should've typed "STORE_COUNTRY".

 

This will base dynamically populate your forms with your stores Country as a default in the country drop-down list.

Posted

I actually do have right stuff in the catalog/includes/functions/html_output.php file:

 

// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = STORE_COUNTRY, $parameters = '') {
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = tep_get_countries();

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }

 

And it does populate the countries fine. What is not populating automatically is the states. For this I have on the create_account.php file the following:

 

 

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

// Populate US States Drop-Down as Default Automatically when Page Loads
 if ($country = '') {

 $country = STORE_COUNTRY;

}

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 

Now this ain't working. Any ideas?

 

Thanks,

Archived

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

×
×
  • Create New...