Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Create_account - State Pulldown menu problem


remedyx

Recommended Posts

Posted

I'm having a problem, that i'm sure a PHP programer would resolve in a minute..

 

The module i'm using (brazilian portuguese), have this blank space for that i can put the State i'm from.. It already is linked to the MySQL DB, but the pulldown menu, with all the states, just appears, when i wrote all the form, click the submit buttom, and some of the informations is wrong...

 

ie.: i type "SP" in the state field, but the birth date format is wrong, when i submit the form, appears the same screen, telling me that the date is in incorrect format, BUT, there's an "AC" at the State field (that is the first state at the database), BUT NOW the pulldown menu is working...

 

I'm a newbie in PHP, but i'm quite sure, that the problem, is in create_account.php, at the following lines..:

 

<?php

  if (ACCOUNT_STATE == 'true') {

?>

              <tr>

                <td class="main"><?php echo ENTRY_STATE; ?></td>

                <td class="main">

   

<?php

    if ($process == true) {

      if ($entry_state_has_zones == true) {

        $zones_array = array();

        $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");

        while ($zones_values = tep_db_fetch_array($zones_query)) {

          $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

        }

        echo tep_draw_pull_down_menu('state', $zones_array);

      } else {

        echo tep_draw_input_field('state');

      }

    } else {

 

      echo tep_draw_input_field('state');

    }

 

    if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;

?>

 

                </td>

              </tr>

<?php

  }

?>

              <tr>

                <td class="main"><?php echo ENTRY_COUNTRY; ?></td>

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

              </tr>

 

Besides, the COUNTRY pulldown menu, is working since the first time i'm at the form... Just the state pulldown menu, that is now working at the beggining.. Just when cames an error of some information... So the linkage with the database is working... I thing it's just a condition at the code, so that the state pulldown could be displayed since the first screen..

 

Please, inform if i need to send some other codes, or files, for that you guys could help me out...

 

It's my first time at this forum... I really hope to hear from somebody soon...

 

Thanks in advance..

 

R .:

  • Replies 77
  • Created
  • Last Reply
Posted

Anyone how could help me.... Please.. I'm in a really tight deadline with this... Please, some expert in PHP, HEEEEELP !!! :(

 

Thanks in advance...

 

R.:

Posted

That is the default behavior of the state field. The system uses a textbox for the state and a dropdown listing for the country. If the state is not valid for that country, then the form is displayed again with a dropdown listing for the state based on the countries zones.

 

I think what you are asking is can the state be a dropdown listing instead of a textbox when the form first loads. If you are only shipping to one country, then it can be done through the PHP code. If you are shipping to multiple countries, then it would be difficult since the user has not selected a country yet, so you don't know what the countries zones are.

I'd rather be flying!

Posted

YES !!! EXACTLY !!! I only ship to one country... And all i want, is that, all the time, the State dropdown menu appears, with all the states at the database..

 

Quoted, is the code from create_account.php ... I think that's the problem, because i change one line, and the dropdown menu appears, but empty...

 

I know too, that at general.php have some table with the country dropdown menu... As long the States dropdown appears at the second time you try to create the account, i just have to figure, where to edit, to make it appears all the time..

 

bluepony, thanks for this so fast answer... Please, help me out with it...

 

Thanks, thanks, thanks...

 

R.:

Posted

Hi remedyx

 

Just replace this block of code in create_account.php:

<?php
?if (ACCOUNT_STATE == 'true') {
?>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><?php echo ENTRY_STATE; ?></td>
? ? ? ? ? ? ? ?<td class="main">
? ?
<?php
? ?if ($process == true) {
? ? ?if ($entry_state_has_zones == true) {
? ? ? ?$zones_array = array();
? ? ? ?$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
? ? ? ?while ($zones_values = tep_db_fetch_array($zones_query)) {
? ? ? ? ?$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
? ? ? ?}
? ? ? ?echo tep_draw_pull_down_menu('state', $zones_array);
? ? ?} else {
? ? ? ?echo tep_draw_input_field('state');
? ? ?}
? ?} else {

? ? ?echo tep_draw_input_field('state');
? ?}

? ?if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
?>

? ? ? ? ? ? ? ?</td>
? ? ? ? ? ? ?</tr>
<?php
?}
?>

 

with this code:

<?php
?if (ACCOUNT_STATE == 'true') {

?// Default to Brazil and always show states
?$country = 30;
?$entry_state_has_zones = true;
?>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><?php echo ENTRY_STATE; ?></td>
? ? ? ? ? ? ? ?<td class="main">
? ?
<?php
? ? ?if ($entry_state_has_zones == true) {
? ? ? ?$zones_array = array();
? ? ? ?$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
? ? ? ?while ($zones_values = tep_db_fetch_array($zones_query)) {
? ? ? ? ?$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
? ? ? ?}
? ? ? ?echo tep_draw_pull_down_menu('state', $zones_array);
? ? ?} else {
? ? ? ?echo tep_draw_input_field('state');
? ? ?}

? ?if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
?>

? ? ? ? ? ? ? ?</td>
? ? ? ? ? ? ?</tr>
<?php
?}
?>

I'd rather be flying!

Posted

Bluepony !!!!!! Man, oh man.... I don't know how to thank you !!!

 

That was really a big problem... And you solved it...

 

Thanks, thanks, thanks !!!!

 

 

I have some other doubts about access some variables of PHP, thought Flash... The site i'm making, have a flash top menu, and i want to make it access some files...

 

I heard a guy that makes this access thought an external .txt, to get the database infos too... Do you know some about it ?

 

 

Thanks again man... Your name is at the code !!!! :D

 

R.:

  • 2 weeks later...
Posted

thnaks for the tip , so to find the code to another country i can try to see the values of country in the database ? and change the $country = 30; to something else !?

MS2

Posted

Hi there.

 

In my webshop, I have had some problems with people failing the registration, due to the fact that the state is a textbox, and the countries a dropdown box. The problem is this: Some countries don't use "state", so for them, it is quite unusual. So, if I put in all the states in the database, and they select their country, and not the state, then they have to find the state , AND select the country again.

 

Is there anyone that can make the following modification (as I have seen in other systems):

Put the country before State, and, when the country has been selected, load the states in a drop-down box for the country (or setting the country_has_states or something), so the drop-down for state would load automagically....

 

Anyone?

  • 3 weeks later...
Posted

Very nice contributuion, I just finished installing it and Ive come across the problem of the state being needed no matter what country they choose.

 

Example:

 

241 My Address

Sometown

California, Christmas Island 32412

 

Just wondering if there is a simple fix to this.

 

UPDATE: Just saw Stevel's contrib, might do what I need.

 

Thanks,

KennethS

Kenneth S

--------------

Customer "Are you a real programmer?"

Me "No, but I did stay at a Holiday Inn Express last night"

Posted

Hi!

Do you know of a way for this to work for the adress_book_process.php where you can edit and add addresses.

 

The drop down state selection menu does not appear there with your script.

 

Thanks for your time and effort!

Posted

I have a problem with the dropdown menu, when people create a new account the drop down country menu is very long for most new net people. It can put them off creating an account.

I figure that I have 2 choices, make the country list smaller, problem with this is that I dont know who my best customers will be yet, I'm also worried this may upset other features in oscommerce and mess it up. i.e shipping areas?

The other option is to put the most popular countries at the start of the dropdown list, so most people wont have to scroll too far.

Does anyone know how this is done? :unsure:

Posted

I think most people are used to long country lists in menus. If you wanted to add common countries to the front, you'd create a small array with those countries and "concatenating" them so that the new elelemts were at the beginning. I don't know enough PHP to suggest how to do that.

 

However, the approach I take is to have a default country pre-selected, that being my own country where most orders are from. That may or may not help if you get lots of orders from other countries, but people seem to understand it.

Posted

I only plan to ship within the United States but the create_account page does not offer the dropdown box for the state field even though the United States is listed as the default and only country.

 

I copied and pasted the code above provided by bluepony and changed the country code to 223 for the United States. However, the state drop down box still does not display. :blink:

 

Any suggestions?

Posted
However, the approach I take is to have a default country pre-selected, that being my own country where most orders are from. That may or may not help if you get lots of orders from other countries, but people seem to understand it.

Hi can you tell me how to make the United States the default?

 

Thanks in advance.

G.B

Posted

I use my Country-State Selector contribution which provides that.

 

There used to be a "wiki" document that explained how to do it simply, but I can't find it in the new Knowledge Base and I have forgotten the details. Someone else can probably point to a description.

  • 4 months later...
Posted
Hi can you tell me how to make the United States the default?

 

Thanks in advance.

G.B

 

Steve's modification/contribution is the bomb.

 

But, to answer G.B.s question, if you are not using Steve's contribution, for those wishing to change the default country to the USA on the drop down simply do this:

 

 

1. open catalog/includes/functions/html_output.php

around line 289:

 $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

 

Change To:

 $countries_array = array(array('id' => '223', 'text' => 'United States'));

 

Dat's all! :thumbsup:

  • 2 weeks later...
Posted

[installed, US selected, all "states" show up even outside us. where can i delete the extra "states", we only sell within US??

Posted
[installed, US selected, all "states" show up even outside us. where can i delete the extra "states", we only sell within US??

 

 

never mind . .. used phpMyAdmin

Posted

I too need HELP with the State Dropdown menu, Unlike other post, mine is a little different. It was working fine, I have not changed anything but for some reason I now have this problem. When a customer goes to add a profile / account the create account form takes all the information as it should and will create an account in any state other than North Carolina. When a customer enters the State, North Carolina and then United States. and clicks continues, the page loads with an error message telling the customer to pick a State from the dropdown menu. When the customer clicks the dropdown menu to locate the state, North Carolina is listed 4 times and when North Carolina is placed in the form, the form continues to give the same error message, The customer can select any other state and the form works correct. How do I fix this problem? Why is North Carolina showing up in the form 4 times?

 

Take a look, and try it yourself so maybe you or somebody can give me advise!

 

https://globalnet-marketing.net/catalog/create_account.php

 

Thanks in Advance..

 

Greg

Posted
I too need HELP with the State Dropdown menu, Unlike other post, mine is a little different. It was working fine, I have not changed anything but for some reason I now have this problem. When a customer goes to add a profile / account  the create account form takes all the information as it should and will create an account in any state other than North Carolina. When a customer enters the State, North Carolina and then United States. and clicks continues, the page loads with an error message telling the customer to pick a State from the dropdown menu. When the customer clicks the dropdown menu to locate the state, North Carolina is listed 4 times and when North Carolina is placed in the form,  the form continues to give the same error message, The customer can select any other state and the form works correct. How do I fix this problem? Why is North Carolina showing up in the form 4 times?

 

Take a look, and try it yourself so maybe you or somebody can give me advise!

 

https://globalnet-marketing.net/catalog/create_account.php

 

Thanks in Advance..

 

Greg

 

 

I would check the database using phpMyAdmin (if you need more help feel free to email me)

  • 4 months later...
Posted

I have this contribution integrated in my store and it works great, the problem is that I also have purchase without account installed, and if the customer goes down that route, then the drop down box for selecting state isn't displayed.

 

Has anyone integrated the dropdown into the purchase without account pages???

 

Any help would be much appreciated, thanks :thumbsup:

 

If you need me to post any of the PWA code please let me know.

Posted
I have this contribution integrated in my store and it works great, the problem is that I also have purchase without account installed, and if the customer goes down that route, then the drop down box for selecting state isn't displayed.

 

Has anyone integrated the dropdown into the purchase without account pages???

 

Any help would be much appreciated, thanks  :thumbsup:

 

If you need me to post any of the PWA code please let me know.

 

 

I use this code in order_info_check.php for the state and country.

I do use the tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); function though which sets the initial country code based on the browser language settings.

 

 

<tr>

<td class="main" align="right"> <?php echo ENTRY_STATE; ?></td>

<?php

$state = tep_get_zone_name($country, $zone_id, $state);

if ($country == ''){

$country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true);

if ($country == ''){

$country = DEFAULT_COUNTRY;

}

}

 

$zones_array = array();

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");

while ($zones_values = tep_db_fetch_array($zones_query)) {

$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

}

echo '<td class="main"> ' . tep_draw_pull_down_menu('state', $zones_array,'', ' class="inputBox" ') . '</td>';

?>

 

<td class="main" align="right"> <?php echo ENTRY_COUNTRY; ?></td>

 

<?php

if ($country == ''){

$country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true);

if ($country == ''){

$country = DEFAULT_COUNTRY;

}

}

$account['entry_country_id'] = $country;

echo '<td class="main"> ' . tep_get_country_list('country', '', 'onchange="account_edit.submit()" class="inputBox" ') . '</td>';

?>

</tr>

Treasurer MFC

Archived

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

×
×
  • Create New...