Jump to content

Archived

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

gogowanda

US state dropdown list in customer account creation

Recommended Posts

That last post by webguy was REALLY helpful. His trick worked!

 

Just wondering thou...how do you change the other files that add addresses to users accounts...like :

 

catalog/checkout_payment_address.php

catalog/modules/checkout_new_address.php

 

 

Should have the drop down thru out the site to maintain consistancy...

 

Anyone?

Thanks, I missed that one.

Make the exact same changes to includes/modules/checkout_new_address.php as in catalog/create_account.php

That seems to do it for both checkout_payment_address and checkout_new_address.

Share this post


Link to post
Share on other sites
in catalog/create_account.php,

replace:

 

CODE 

<?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

}

?>

 

Jason...What version of OSC has this in create_account.php? I'm running 2.2CVS and this bit of code is nowhere to be found in my create_account.php file, but is in account_details.php, et al...Just looking for clarification on what you're suggesting.

Share this post


Link to post
Share on other sites

Again...kudos to webguy for making this easy

 

Im having trouble with modifying checkout_payment_address.php

 

 

any code hints here?

Share this post


Link to post
Share on other sites
...

 

Im having trouble with modifying checkout_payment_address.php

 

 

any code hints here?

Using 2.2MS2, at least, I didn't have to do anything to checkout_payment_address.php.

On [or about] line 416,

<td><?php require(DIR_WS_MODULES . 'checkout_new_address.php'); ?></td>

inserts one of the files that I modified earlier [look HERE].

If it's not working for you, there's gotta be some circumstance I haven't tested yet or something.

Share this post


Link to post
Share on other sites
...

 

Im having trouble with modifying checkout_payment_address.php

 

 

any code hints here?

Using 2.2MS2, at least, I didn't have to do anything to checkout_payment_address.php.

On [or about] line 416,

<td><?php require(DIR_WS_MODULES . 'checkout_new_address.php'); ?></td>

inserts one of the files that I modified earlier [look HERE, and HERE].

If it's not working for you, there's gotta be some circumstance I haven't tested yet or something.

Share this post


Link to post
Share on other sites

I also added a new zone to United States -Outside North America with XX as the state code...

 

seems to work so that at least other countries can still create accounts.

 

It would be nice to get the entire zones into a dropdown though.

Share this post


Link to post
Share on other sites

hey everyone. I have been trying to get this to work. It doesn't seem like it should be hard at all. But no matter who's version of code I paste into create_account.php I just end up with a blank page.

 

No error, no nothing... just blank white.

 

any ideas?

Share this post


Link to post
Share on other sites

I used the code and it worked great! :D

 

On some sites I've seen an option for people outside the US to manually enter their state. Some suggestions?

Share this post


Link to post
Share on other sites

Guys- does the possibility exist that if I made any of the changes mentioned in this thread to create_account.php and related files, that upon checkout, the shipping information passed to authorize.net would allow for the country in the customer's shipping address to be listed simply as "array"?

 

Here's my data that's being passed to Authorize.net, and their techs say it's failing because of the shipping address. They say everything else looks fine.

 

 

Settlement Information

Settlement Amount: USD 3.81

Settlement Date and Time: --

Authorization Information

Authorization Amount: USD 3.81

Submit Date /Time: --

Authorization Code: 000000

Reference Transaction ID: Not Applicable

Transaction Type: Authorization Only

Address Verification Status: AVS Not Applicable (P)

Card Code Status: Not Processed

CAVV Result Code: Not Applicable

Fraud Score Applied: Not Applicable

Recurring Billing Transaction: N

Partial Capture Status: Not Applicable

Payment Information

Card Type: Discover

Card Number: XXXX0012

Expiration Date: XXXX

Total Amount: USD 3.81

Order Information

Invoice #:

Description: Your Products Description

Customer Billing Information

Name: Frederick Smith

Company:

Address: 122 Front Street

City: Anytown

State/Province: Massachusetts

Zip Code: 01056

Country: United States

Phone: 413-555-1212

Fax:

Email: fsmith@xxxxxx.com

 

Customer ID: 23

Customer Type:

Customer TaxID/SSN:

 

DL Number:

DL State:

DL DOB:

 

Shipping Information

Name: Frederick Smith

Company:

Address: 122 Front Street

City: Anytown

State/Province: Massachusetts

Zip Code: 01056

Country: Array

Phone: 413-555-1212

Additional Details - Level 2 Data

Tax: 0

Freight: 0

Duty: 0

Tax Exempt: N

PO Number:

Share this post


Link to post
Share on other sites
Guys- does the possibility exist that if I made any of the changes mentioned in this thread to create_account.php and related files, that upon checkout, the shipping information passed to authorize.net would allow for the country in the customer's shipping address to be listed simply as "array"?
Array is what it puts when the country didn't get assigned correctly. I would start by checking the database for the address_book entry: see if it has the correct data. If it does, then it isn't being read properly. If it does not, then it's not being written correctly when the account is being created.

 

Given the data you show, I find it more likely that it isn't being loaded properly. Maybe a spelling mistake in either the query or the variable assignment? Are you posting to the authorize.net page from the checkout_confirmation page? Or using something like curl to connect to authorize.net on the checkout_process page?

 

Hth,

Matt


Always backup before making changes.

Share this post


Link to post
Share on other sites
I used the code and it worked great! :D

 

On some sites I've seen an option for people outside the US to manually enter their state. Some suggestions?

I'd love the answer to this, too. I suppose I could just add an extra field to the forms for customers from other countries to enter their details. What have others done with this?

 

TIA,

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

I noticed today a nice one in enoms control panel. The have state providence or not applicable in 3 forms on radio buttons Dials it right in for a global solution

Share this post


Link to post
Share on other sites
On some sites I've seen an option for people outside the US to manually enter their state. Some suggestions?
Around lines 38-45 of create_account.php, change
    if (ACCOUNT_STATE == 'true') {
     $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
     if (isset($HTTP_POST_VARS['zone_id'])) {
       $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
     } else {
       $zone_id = false;
     }
   }

to

    if (ACCOUNT_STATE == 'true') {
     $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
     if (isset($HTTP_POST_VARS['region']) && tep_not_null($HTTP_POST_VARS['region'])) {
       $state = tep_db_prepare_input($HTTP_POST_VARS['region']);
     }
     if (isset($HTTP_POST_VARS['zone_id'])) {
       $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
     } else {
       $zone_id = false;
     }
   }

Around line 425, change

        echo tep_draw_pull_down_menu('state', $zones_array);

to

        echo tep_draw_pull_down_menu('state', $zones_array) . '<br>' . tep_draw_input_field('region');

I forget how the other changes in this thread affected things...you may have to adjust this slightly. Also, we could be more explanatory about what the new field does. Basic functionality should be here though.

 

Hth,

Matt


Always backup before making changes.

Share this post


Link to post
Share on other sites

Thanks, Matt -- that works! (Haven't tested it yet to see how it flows through the other forms, but will post my results.)

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

One little problem... when I try to submit my form using the new field, I get a JS error saying state field needs to be a minimum of 2 characters. (US State field shows as 'please select'.) Is there a way around the error?

 

TIA,

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

In includes/form.check.js.php, around line 30, add

function check_input2(field_name, field_name2, field_size, message) {
 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
   var field_value = form.elements[field_name].value;
   var field_value2 = form.elements[field_name2].value;

   if (field_value == '' || (field_value.length < field_size && field_value2.length < field_size)) {
     error_message = error_message + "* " + message + "\n";
     error = true;
   }
 }
}

Around line 129, change to

<?php if (ACCOUNT_STATE == 'true') echo '  check_input2("state", "region", ' . ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '");' . "\n"; ?>

I think that would fix it.

 

Hth,

Matt


Always backup before making changes.

Share this post


Link to post
Share on other sites

Thanks for trying, Matt. Unfortunately, I'm still getting the same error after changing the code as above. :(

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

I've read this entire thread and I still don't have a drop down box for the US states. I have my zones set in admin, do I have have to turn "states" on somewhere?

 

Since I upgraded, I've had to contact my customers to find out which state they reside in. I have a dropdown box for Countries why is the States box such a difficult thing to code?

 

Can anyone give me a fix for this problem?

 

Thanks!

Share this post


Link to post
Share on other sites

Thanks Matti and WebGuy for posting the info on how to do this stuff. Works great in my site.

My question now:

If an error occurs in entry (specifically in addition I use the VVC Code mod), the page "resets" with some data saved, some data cleared. The State/Province goes back to "select," the Password is blanked, and the VVC Code is reset (which itself is fine).

Is it possible to have the State/Prov not get reset back to default, just as the Country remains whatever was selected?

I know this much about php --> .

Which is why I'm asking here.

TIA--

--Jeff


--Jeff

Of course I don't look busy! I did it right the first time!

Share this post


Link to post
Share on other sites

×