Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

problem with address book


Guest

Recommended Posts

hey, i have just started work on my second attempt at my OSC install.

 

http:www.poiinthepark.net/phposc/default.php

 

still in editing stages but i have found a flaw in which i can not sort out?

 

all the account sign up pages work, but upon testing i found that if you wish to use the add address feature in the accounts pages, i can not add alternative addresses. In the address book it lists my account address for billing and such, but with the option to add other addresses for shipping [which i like and want to keep] it will let me fill out the form address_book_process but then on pressing continue i am returned to the same form i have just filled out with the same details i have just typed in to add to my address book. I am presuming that once continue has been clicked then i would be sent back to my address book and should see the new address i have added to my account!

 

but it does not happen, could some one help me out with this? i'd be very greatful if some one could. Also any feed back on the design front would be good too, this is my first time getting into the nitty gritty side of php and finding that mostly OSC is quite easy to modify and is so durable you can do what ever you like, but i cant get my head around this one! :shock:

 

<?php

/*

 $Id: address_book_process.php,v 1.72 2002/09/26 13:42:53 project3000 Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 require('includes/application_top.php');



 if (!tep_session_is_registered('customer_id')) {

   $navigation->set_snapshot();

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

 }



 if ( ($navigation->snapshot['page'] != FILENAME_ADDRESS_BOOK) || ($navigation->snapshot['page'] != FILENAME_CHECKOUT_ADDRESS) ) {

   $navigation->set_path_as_snapshot(1);

 }



 if ( ($HTTP_GET_VARS['action'] == 'remove') && (tep_not_null($HTTP_GET_VARS['entry_id'])) ) {

   $entry_id = tep_db_prepare_input($HTTP_GET_VARS['entry_id']);

   tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . tep_db_input($entry_id) . "' and customers_id = '" . $customer_id . "'");

   tep_db_query("update " . TABLE_ADDRESS_BOOK . " set address_book_id = address_book_id - 1 where address_book_id > " . tep_db_input($entry_id)  . " and customers_id = '" . $customer_id . "'");

   tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));

 }



// Post-entry error checking when updating or adding an entry

 $process = false;

 if (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'update')) {

   $process = true;

   $error = false;



   $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);

   $company = tep_db_prepare_input($HTTP_POST_VARS['company']);

   $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);

   $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);

   $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);

   $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);

   $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);

   $city = tep_db_prepare_input($HTTP_POST_VARS['city']);

   $country = tep_db_prepare_input($HTTP_POST_VARS['country']);

   $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);

   $state = tep_db_prepare_input($HTTP_POST_VARS['state']);



   if (ACCOUNT_GENDER == 'true') {

     if (($gender == 'm') || ($gender == 'f')) {

       $gender_error = false;

     } else {

       $gender_error = true;

       $error = true;

     }

   }



   if (ACCOUNT_COMPANY == 'true') {

     if (strlen($company) < ENTRY_COMPANY_MIN_LENGTH) {

       $company_error = true;

       $error = true;

     } else {

       $company_error = false;

     }

   }



   if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

     $firstname_error = true;

     $error = true;

   } else {

     $firstname_error = false;

   }



   if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

     $lastname_error = true;

     $error = true;

   } else {

     $lasttname_error = false;

   }



   if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {

     $street_address_error = true;

     $error = true;

   } else {

     $street_address_error = false;

   }



   if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

     $postcode_error = true;

     $error = true;

   } else {

     $postcode_error = false;

   }



   if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {

     $city_error = true;

     $error = true;

   } else {

     $city_error = false;

   }



   if (!$country) {

     $country_error = true;

     $error = true;

   } else {

     $country_error = false;

   }



   if (ACCOUNT_STATE == 'true') {

     if ($entry_country_error) {

       $entry_state_error = true;

     } else {

       $zone_id = 0;

       $entry_state_error = false;

       $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "'");

       $check_value = tep_db_fetch_array($check_query);

       $entry_state_has_zones = ($check_value['total'] > 0);

       if ($entry_state_has_zones) {

         $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "' and zone_name = '" . tep_db_input($state) . "'");

         if (tep_db_num_rows($zone_query) == 1) {

           $zone_values = tep_db_fetch_array($zone_query);

           $zone_id = $zone_values['zone_id'];

         } else {

           $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "' and zone_code = '" . tep_db_input($state) . "'");

           if (tep_db_num_rows($zone_query) == 1) {

             $zone_values = tep_db_fetch_array($zone_query);

             $zone_id = $zone_values['zone_id'];

           } else {

             $error = true;

             $entry_state_error = true;

           }

         }

       } else {

         if (!$state) {

           $error = true;

           $entry_state_error = true;

         }

       }

     }

   }



   if ($error == false) {

     $sql_data_array = array('entry_firstname' => $firstname,

                             'entry_lastname' => $lastname,

                             'entry_street_address' => $street_address,

                             'entry_postcode' => $postcode,

                             'entry_city' => $city,

                             'entry_country_id' => $country);



     if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;

     if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;

     if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;

     if (ACCOUNT_STATE == 'true') {

       if ($zone_id > 0) {

         $sql_data_array['entry_zone_id'] = $zone_id;

         $sql_data_array['entry_state'] = '';

       } else {

         $sql_data_array['entry_zone_id'] = '0';

         $sql_data_array['entry_state'] = $state;

       }

     }



     $entry_id = tep_db_prepare_input($HTTP_POST_VARS['entry_id']);

     if ($HTTP_POST_VARS['action'] == 'update') {

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . tep_db_input($entry_id) . "' and customers_id ='" . tep_db_input($customer_id) . "'");

     } else {

       $sql_data_array['customers_id'] = $customer_id;

       $sql_data_array['address_book_id'] = $entry_id;

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);



// Go back to where we came from

       if (sizeof($navigation->snapshot) > 0) {

         $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

         $navigation->clear_snapshot();

         tep_redirect($origin_href);

       }

     }

     tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));

   }

 }



 if (($HTTP_GET_VARS['action'] == 'modify') && ($HTTP_GET_VARS['entry_id'])) {

   $entry_query = tep_db_query("select entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_zone_id, entry_country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "' and address_book_id = '" . $HTTP_GET_VARS['entry_id'] . "'");

   $entry = tep_db_fetch_array($entry_query);

 } else {

   $entry = array('entry_country_id' => STORE_COUNTRY);

 }



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADDRESS_BOOK_PROCESS);



 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));



 if ( ($HTTP_GET_VARS['action'] == 'modify') || ( ($HTTP_POST_VARS['action'] == 'update') && ($HTTP_POST_VARS['entry_id']) ) ) {

   $breadcrumb->add(NAVBAR_TITLE_MODIFY_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'action=modify&entry_id=' . ((isset($HTTP_GET_VARS['entry_id'])) ? $HTTP_GET_VARS['entry_id'] : $HTTP_POST_VARS['entry_id']), 'SSL'));

 } else {

   $breadcrumb->add(NAVBAR_TITLE_ADD_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, '', 'SSL'));

 }

?>

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

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<script language="javascript"><!--

function check_form() {

 var error = 0;

 var error_message = "<?php echo JS_ERROR; ?>";



 var firstname = document.add_entry.firstname.value;

 var lastname = document.add_entry.lastname.value;

 var street_address = document.add_entry.street_address.value;

 var postcode = document.add_entry.postcode.value;

 var city = document.add_entry.city.value;



<?php

if (ACCOUNT_GENDER == 'true') {

?>

 if (document.add_entry.elements['gender'].type != "hidden") {

   if (document.add_entry.gender[0].checked || document.add_entry.gender[1].checked) {

   } else {

     error_message = error_message + "<?php echo JS_GENDER; ?>";

     error = 1;

   }

 }

<?php

}

?>

 if (firstname == "" || firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";

   error = 1;

 }



 if (lastname == "" || lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_LAST_NAME; ?>";

   error = 1;

 }



 if (street_address == "" || street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_ADDRESS; ?>";

   error = 1;

 }



 if (postcode == "" || postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_POST_CODE; ?>";

   error = 1;

 }



 if (city == "" || city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {

   error_message = error_message + "<?php echo JS_CITY; ?>";

   error = 1;

 }

<?php

 if (ACCOUNT_STATE == 'true') {

?>

 if (document.add_entry.state.value == "" || document.add_entry.state.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?> ) {

    error_message = error_message + "<?php echo JS_STATE; ?>";

    error = 1;

 }

<?php

 }

?>



 if (document.add_entry.country.value == 0) {

   error_message = error_message + "<?php echo JS_COUNTRY; ?>";

   error = 1;

 }



 if (error == 1) {

   alert(error_message);

   return false;

 } else {

   return true;

 }

}

//--></script>

</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 width="760" border="1" align="center" cellpadding="3" cellspacing="3" bordercolor="#000000">

 <tr> 

   <td width="760"><table border="0" width="100%" cellspacing="3" cellpadding="3">

       <tr> 

         <!-- body_text //-->

         <td width="100%" valign="top"><form name="add_entry" method="post" action="<?php echo tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, '', 'SSL'); ?>" onSubmit="return check_form();">

             <table border="0" width="100%" cellspacing="0" cellpadding="0">

               <tr> 

                 <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

                     <tr> 

                       <td class="pageHeading"><?php echo ($HTTP_GET_VARS['action'] == 'modify') ? HEADING_TITLE_MODIFY_ENTRY : HEADING_TITLE_ADD_ENTRY; ?></td>

                       <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_address_book.gif', ($HTTP_GET_VARS['action'] == 'modify') ? HEADING_TITLE_MODIFY_ENTRY : HEADING_TITLE_ADD_ENTRY, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

                     </tr>

                   </table></td>

               </tr>

               <tr> 

                 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

               </tr>

               <tr> 

                 <td> 

                   <?php include(DIR_WS_MODULES . 'address_book_details.php'); ?>

                 </td>

               </tr>

               <tr> 

                 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

               </tr>

               <?php

   if (($HTTP_GET_VARS['action'] == 'modify') && ($HTTP_GET_VARS['entry_id'])) {

?>

               <tr> 

                 <td><table border="0" width="100%" cellspacing="2" cellpadding="0">

                     <tr> 

                       <td class="main"><input type="hidden" name="action" value="update"> 

                         <input type="hidden" name="entry_id" value="<?php echo $HTTP_GET_VARS['entry_id']; ?>"> 

                         <a href="<?php echo tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'); ?>"><?php echo tep_image_button('button_back.gif', IMAGE_BUTTON_BACK); ?></a></td>

                       <td class="main" align="center"><a href="<?php echo tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'action=remove&entry_id=' . $HTTP_GET_VARS['entry_id'], 'SSL'); ?>"><?php echo tep_image_button('button_delete.gif', IMAGE_BUTTON_DELETE); ?></a></td>

                       <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

                     </tr>

                   </table></td>

               </tr>

               <?php

   } elseif (($HTTP_POST_VARS['action'] == 'update') && ($HTTP_POST_VARS['entry_id'])) {

?>

               <tr> 

                 <td><table border="0" width="100%" cellspacing="2" cellpadding="0">

                     <tr> 

                       <td class="main"><input type="hidden" name="action2" value="update"> 

                         <input type="hidden" name="entry_id" value="<?php echo $entry_id; ?>"> 

                         <a href="<?php echo tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'); ?>"><?php echo tep_image_button('button_back.gif', IMAGE_BUTTON_BACK); ?></a></td>

                       <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

                     </tr>

                   </table></td>

               </tr>

               <?php

   } else {

     if (sizeof($navigation->snapshot) > 0) {

       $back_link = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

     } else {

       $back_link = tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL');

     }

?>

               <tr> 

                 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

                     <tr> 

                       <td class="main"><?php echo '<a href="' . $back_link . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

                       <td align="right" class="main"><input type="hidden" name="entry_id" value="<?php echo ($HTTP_GET_VARS['entry_id'] ? $HTTP_GET_VARS['entry_id'] : $entry_id); ?>"> 

                         <input type="hidden" name="action2" value="process"> 

                         <?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

                     </tr>

                   </table></td>

               </tr>

               <?php

   }

?>

             </table>

           </form></td>

         <!-- body_text_eof //-->

     </table></td>

       </tr>

     </table>

<!-- body_eof //-->

 

hope some one can help.

Link to comment
Share on other sites

  • 3 months later...

I would actually look into the address_book_detail.php file as the problem as that is the file that gets called when doing an add/edit to an address book. Find it in catalog/includes/modules. If that is defunct then you will never change an addy.

 

I do not see however, how it could actually be that file as it seems to be a POST issue (pressing continue). So I would say looik at your database for clues as to what is going on.

 

Sorry I can't be of more help to you.

Link to comment
Share on other sites

  • 2 months later...

i recieved an email from some one called cathy tonight via this board, i could not return the email as there was no email address to return a mail to.

 

 

i have just tested the add address function on my site and it works fine, i never got around to posting an update on this thread as to how i managed to fix the problem, i think i spent some time looking at the code to make it work as it wasnt calling to add any thing to the database via the ....detail.php file.

 

i am running osc currently as a module on a nuke 6.9 site and it works fine.

i am currnetly finishing off setting up the shop as i now have the cash to do so as a spare time buisness for my site users and to generate some cash in the future if all goes well.

 

if you wish to check out my site the address is http://www.poiinthepark.net

 

cathy if you are still struggling them email form your emaill address and not the forums here and i will send you the php file as mine works for sure.

 

 

be kewl.

Link to comment
Share on other sites

  • 2 years later...

Archived

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

×
×
  • Create New...