Jump to content
stevel

Country-State Selector

Recommended Posts

address_book_details is in includes/modules.  It is common functionality for address book pages.  If the company_tax_id is a field in the address book record, then you would add it at least as a hidden form field and a variable so that it gets written to the database properly.  Your interest is in making sure the data gets carried along and written to the order record properly.

 

that pretty much was greek to me.

when is the address_book_details page actually used then?

if the checkout pages dont contain anything related to the company_tax_id now, your saying I should still add it into the section containing your contribution?

Share this post


Link to post
Share on other sites

Steve,

 

first allow me to thank you for this greeeeeat contribution, it is exactly what I've been missing!

 

I've installed it without complications, managed to rearrange few boxes but now I'm stuck with PWA. It uses two files, order_info.php and in modules order_info_check.php where the code is different to address_book_details.php. And as I'm complete newbie to php I would like to ask if you could help me with replacing the correct bits of code in those two files. I know it needs to be replaced, but not quite sure where exactly. I guess this could be appropriate area in order_info_check.php:

} elseif ($error) {
     if ($entry_state_error) {
       if ($entry_state_has_zones) {
         $zones_array = array();
         $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($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) . ' ' . ENTRY_STATE_ERROR;
       } else {
         echo tep_draw_input_field('state') . ' ' . ENTRY_STATE_ERROR;
       }
     } else {
       echo $state . tep_draw_hidden_field('zone_id') . tep_draw_hidden_field('state');
     }
   } else {

 

and the secod part should be around here:

<td class="main"> 
<?php
 if ($is_read_only) {
   echo tep_get_country_name($account['entry_country_id']);
 } elseif ($error) {
   if ($entry_country_error) {
     echo tep_get_country_list('country') . ' ' . ENTRY_COUNTRY_ERROR;
   } else {
     echo tep_get_country_name($country) . tep_draw_hidden_field('country');
   }
 } else {
   echo tep_get_country_list('country', $account['entry_country_id']) . ' ' .'<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT .'</span>';
 }
?></td>

 

I'm not quite sure what to change in order_info.php and as it is just a small file, I'll post it here:

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<?php require('includes/form_check.js.php'); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><form name="account_edit" method="post" <?php echo 'action="' .
tep_href_link('order_info_process.php', '', 'SSL')
. '"'; ?> onSubmit="return check_form(this);"><input type="hidden" name="action" value="process"><table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
         </tr>
<?php
 if (sizeof($navigation->snapshot) > 0) {
?>
     <tr>
       <td class="smallText"><br><?php echo sprintf(TEXT_ORIGIN_LOGIN, tep_href_link(FILENAME_LOGIN, tep_get_all_get_params(), 'SSL')); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></td>
     </tr>
     <tr>
       <td>
<?php
 $email_address = tep_db_prepare_input($HTTP_GET_VARS['email_address']);
 $account['entry_country_id'] = STORE_COUNTRY;

 require(DIR_WS_MODULES . 'order_info_check.php');
?>
       </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

 

I hope it is not too much trouble and again thanks a lot.

 

Alex


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites

Bob, address_book_details is included from two other files and contains common code. If the user does not need to see or edit company_tax_id, you don't need to display or edit it. Just make sure that it gets passed along to wherever it is being used. You are going to have to learn at least a bit of PHP to be successful at modifying an osCommerce store. If it's Greek to you, then you need to start learning Greek. A basic understanding of how forms are processed and information passed around in the store is essential, if you're modifying the code yourself.

 

Alex, I'll try to figure this out, but it will probably take a few days.

Share this post


Link to post
Share on other sites

Usually I do hack around until I figure it out myself. Besides giving my store a total facelift to match my regular site, this is about the 18th contribution ive added. I think i just have the jitters now because im ALMOST done(hopefully) and I dont want to botch it all up now :P . SO.....before I do anything that "i think" could cause major headaches I like to have the pro's give me alittle help so I know im on the right track.

 

I appreciate the help, trust me.

 

Im going to give this a test run right now and see how she goes! I think the address_book_process file is the only one I need to worry about my company_tax_id field in. The sad part is that im unsure about adding it to your contrbution because its not an editable field on that page.....the company_tax_id field is displayed but the user can not change it, so i dont know if i need to add the line to your code or not. We'll see I guess.

Share this post


Link to post
Share on other sites

You probably don't need to add it, but I'm unsure how you are using it, so the best thing is to try it out the way you have it and see if it works the way you want. If the tax id is part of the customer record and not used for shipping or billing addresses different from what the customer record has, then you can leave it out. Address book entries are separate from the customer record.

Share this post


Link to post
Share on other sites

ive asked elsewhere, but maybe you would know this too.....

 

everything seems to be working well so far except one thing. Now on the address_book_process page everything is OK at first. The company tax ID field from the SPPC contribution is actually not an editable field on this page...it simply displays what was originally entered by the customer upon registration. BUT, when you change the country and the page refreshes....the company tax ID field becomes an empty editable box. Any thoughts on why im losing the tax id and its becoming an empty box?

 

I tried numerous ideas after the " if (ACCOUNT_COMPANY == 'true') $entry['entry_company'] = $company;" line in that file, but nothing helped.

Share this post


Link to post
Share on other sites
Alex, I'll try to figure this out, but it will probably take a few days.

Thank you very much, appreciate your help. Shall I PM you the files or is it OK the way I posted it?

 

Alex


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites

this mod works perfectly on an already heavily modified system.

 

good work...

 

anyone know where I can download more zones? preferably something that I wouldn't have to use the admin panel to enter them with.

 

my client wants to be able to pretty much ship ANYWHERE.....I said "Are you sure? anywhere?" and they said yes.....

 

any suggestions?

 

thanks again

Share this post


Link to post
Share on other sites

Working perfect on my 2.2. What about a hack for the admin side, - updating the customers, I believe it should be in customers.php file ??

 

....any assistance appreciated.

Share this post


Link to post
Share on other sites
I worked on it some, but it's more complex than I thought. I'll keep at it.

 

Hi Steve,

I'm rootin' for the PWA fix as well. I don't know if you remember me, but I posted some info on it in this thread on June 5th. You could look there and see if any of it helps you.

 

Go Steve!!!! You can do it!!!!!!

 

Corinne

Share this post


Link to post
Share on other sites
Started up again on PWA.  Yuck.  What a convoluted way it has of processing the customer details.  But I think I can see how it should go...

 

Go for it Steve! :thumbsup:

 

 

Dave.

Share this post


Link to post
Share on other sites

What a strange thing!

 

I did install the contrib and it works great on create_account.php page, but it doesn't work on address_book_process.php

 

Any ideas what might be wrong?

Share this post


Link to post
Share on other sites

Great contribution. I use it in my live store Hawaii Online Sales and it works great!

 

I'm in the process of changing my store to CRE loaded version 6.15. The problem I am experiencing is the refresh. When changing the country in both new account and in the address book, the states do not refresh.

 

I've searched for anything related to this CRE loaded problem but was unable to locate any solutions.

 

I've read the previous topics and according to the firefox browser java counsole the error is: refresh_form is not defined. I've also looked at my code source and the function refresh_form is not present. I've also checked the /includes/form_check.js.php file and it is referenced from the create_account.php.

 

My develop site is at: Hawaii Online Sales Loaded CRE Develop Site

 

The CRE loaded version is using "Template Install & Configure V1.2" and I believe this is the problem.

 

While making the required modifications to the files (per instructions), I discovered that the html code which is supposed to be contained in create_account.php is not present, and is located in a file named create_account.tpl.php which is located in a directory under "templates/contents".

 

Current instructions, in create_account.php Look for:

Line 418

Replace:

   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');
   }

 

I find in templates/content/create_account.tpl.php:

   
if ($process == true) {
     if ($entry_state_has_zones == true) {
       $zones_array = array();
       $zones_array[] = array('id' => '', 'text' => '');
       $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');
   }

 

I replace it with:

// +Country-State Selector
   $zones_array = array();
   $zones_query = tep_db_query("select zone_id, 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_id'], 'text' => $zones_values['zone_name']);
     }
   if (count($zones_array) > 0) {
     echo tep_draw_pull_down_menu('zone_id', $zones_array);
   } else {
     echo tep_draw_input_field('state');
   }
// -Country-State Selector

 

I also find in templates/content/create_account.tpl.php:

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

 

And I replace it with:

                <?php // +Country-State Selector ?>
               <td class="main"><?php echo tep_get_country_list('country',$country,
                  'onChange="return refresh_form(create_account);"') . ' ' . 
                  (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . 
                  '</span>': ''); ?></td>
               <?php // -Country-State Selector ?>

 

All other code locations/replacements were found alright and no other "special" files were modified.

 

I realize that the problem is with the template system and NOT this contribution.

 

Unfortunately, no one at CRE loaded incorporated your contribution into their build so I am stuck - too bad because I find it hard to believe that people would rather their customers type a state field instead of a drop down selection list.

 

Any help you provide would be greatly appreciated. My develop site is at: Loaded Develop Site

 

Thank you in advance for any help!!


Aloha,

Lawrence

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×