Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Country-State Selector


stevel

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?

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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

Link to comment
Share on other sites

Oh, I'm sure I can. But it's taken me longer to get PWA integrated to my test store than I expected. I'll get back to it this weekend, most likely.

Link to comment
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!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...