Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jun 2007
    Location
    TN
    Posts
    83
    Plugin Contributions
    0

    Default Update Address Book Entry- not updating

    Hello!

    Using version 1.3.7.1. Had a few customers tell me that when they tried to change their primary address, it reverted back to the old address. So, I tried it for myself and found it happened to me as well.

    My site is www.swansoninc.com.

    I have set up a test log in that you can use to see for yourself. The e-mail to use is [email protected] and the password is 12345

    I have already searched the forums and could not find another issue like this, but wondering if it is a problem with my code or a possible bug. Either way, I would love some help.

    My host is godaddy, just switched from Christian Web Host since they were always going offline and could not support e-commerce.

    Thanks for assistance! Blessings....-Amy

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Update Address Book Entry- not updating - bug?

    I can't reproduce the problem using a clean install of v1.3.8a, and I don't recall there ever being such a 'bug' in v1.3.7.1.
    I suspect the problem is likely broken or missing files from your move, or something broken by one of the addons you've installed.


    Moving this out of the Bug Reports area.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jun 2007
    Location
    TN
    Posts
    83
    Plugin Contributions
    0

    Default Re: Update Address Book Entry- not updating

    So, can anyone please help me? The posted fix in another thread does not work for me since it is a different version than what I am using. I am posting the code for the entire file here in case someone wants to see if there is something in there that is causing the conflict.

    Appreciate any help.

    Code:
    <?php
    /**
     * Header code file for the Address Book Process page
     *
     * @package page
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: header_php.php 4824 2006-10-23 21:01:28Z drbyte $
     */
    // This should be first line of the script:
    $zco_notifier->notify('NOTIFY_HEADER_START_ADDRESS_BOOK_PROCESS');
    
    if (!$_SESSION['customer_id']) {
      $_SESSION['navigation']->set_snapshot();
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
    
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    
    /**
     * Process deletes
     */
    if (isset($_GET['action']) && ($_GET['action'] == 'deleteconfirm') && isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      $sql = "DELETE FROM " . TABLE_ADDRESS_BOOK . "
              WHERE  address_book_id = :delete 
              AND    customers_id = :customersID";
    
      $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
      $sql = $db->bindVars($sql, ':delete', $_GET['delete'], 'integer');
      $db->Execute($sql);
    
      $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_DELETION_DONE');
    
      $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success');
    
      zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
    }
    
    /**
     * Set some defaults
     */
      $process = false;
      $zone_name = '';
      $entry_state_has_zones = '';
      $error_state_input = false;
      $state = '';
      $zone_id = 0;
      $error = false;
    /**
     * Process new/update actions
     */
    if (isset($_POST['action']) && (($_POST['action'] == 'process') || ($_POST['action'] == 'update'))) {
      $process = true;
    
      if (ACCOUNT_GENDER == 'true') $gender = zen_db_prepare_input($_POST['gender']);
      if (ACCOUNT_COMPANY == 'true') $company = zen_db_prepare_input($_POST['company']);
      if (ACCOUNT_COMPANY == 'true') $taxid = zen_db_prepare_input($_POST['taxid']);
      $firstname = zen_db_prepare_input($_POST['firstname']);
      $lastname = zen_db_prepare_input($_POST['lastname']);
      $street_address = zen_db_prepare_input($_POST['street_address']);
      if (ACCOUNT_SUBURB == 'true') $suburb = zen_db_prepare_input($_POST['suburb']);
      $postcode = zen_db_prepare_input($_POST['postcode']);
      $city = zen_db_prepare_input($_POST['city']);
    
    
      /**
         * error checking when updating or adding an entry
         */
      if (ACCOUNT_STATE == 'true') {
        $state = zen_db_prepare_input($_POST['state']);
        if (isset($_POST['zone_id'])) {
          $zone_id = zen_db_prepare_input($_POST['zone_id']);
        } else {
          $zone_id = false;
        }
      }
      $country = zen_db_prepare_input($_POST['zone_country_id']);
      //echo ' I SEE: country=' . $country . '&nbsp;&nbsp;&nbsp;state=' . $state . '&nbsp;&nbsp;&nbsp;zone_id=' . $zone_id;
    
      if (ACCOUNT_GENDER == 'true') {
        if ( ($gender != 'm') && ($gender != 'f') ) {
          $error = true;
          $messageStack->add('addressbook', ENTRY_GENDER_ERROR);
        }
      }
    
      if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_FIRST_NAME_ERROR);
      }
    
      if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_LAST_NAME_ERROR);
      }
    
    if (strlen($taxid) < ENTRY_TAXID_MIN_LENGTH) {
          $error = true;
          $messageStack->add('create_account', ENTRY_TAXID_ERROR);
        }
    
      if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_STREET_ADDRESS_ERROR);
      }
    
      if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_CITY_ERROR);
      }
    
      if (ACCOUNT_STATE == 'true') {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ZONES . "
                        WHERE zone_country_id = :zoneCountryID";
        $check_query = $db->bindVars($check_query, ':zoneCountryID', $country, 'integer');
        $check = $db->Execute($check_query);
        $entry_state_has_zones = ($check->fields['total'] > 0);
        if ($entry_state_has_zones == true) {
          $zone_query = "SELECT distinct zone_id, zone_name, zone_code
                         FROM " . TABLE_ZONES . "
                         WHERE zone_country_id = :zoneCountryID
                         AND " . 
                         ((trim($state) != '' && $zone_id == 0) ? "(upper(zone_name) like ':zoneState%' OR upper(zone_code) like '%:zoneState%') OR " : "") .
                        "zone_id = :zoneID
                         ORDER BY zone_code ASC, zone_name";
    
          $zone_query = $db->bindVars($zone_query, ':zoneCountryID', $country, 'integer');
          $zone_query = $db->bindVars($zone_query, ':zoneState', strtoupper($state), 'noquotestring');
          $zone_query = $db->bindVars($zone_query, ':zoneID', $zone_id, 'integer');
          $zone = $db->Execute($zone_query);
    
          //look for an exact match on zone ISO code
          $found_exact_iso_match = ($zone->RecordCount() == 1);
          if ($zone->RecordCount() > 1) {
            while (!$zone->EOF && !$found_exact_iso_match) {
              if (strtoupper($zone->fields['zone_code']) == strtoupper($state) ) {
                $found_exact_iso_match = true;
                continue;
              }
              $zone->MoveNext();
            }
          }
    
          if ($found_exact_iso_match) {
            $zone_id = $zone->fields['zone_id'];
            $zone_name = $zone->fields['zone_name'];
          } else {
            $error = true;
            $error_state_input = true;
            $messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT);
          }
        } else {
          if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
            $error = true;
            $error_state_input = true;
            $messageStack->add('addressbook', ENTRY_STATE_ERROR);
          }
        }
      }
    
      if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_POST_CODE_ERROR);
      }
    
      if (!is_numeric($country)) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_COUNTRY_ERROR);
      }
    
      if ($error == false) {
        $sql_data_array= array(array('fieldName'=>'entry_firstname', 'value'=>$firstname, 'type'=>'string'),
                               array('fieldName'=>'entry_lastname', 'value'=>$lastname, 'type'=>'string'),
                               array('fieldName'=>'entry_street_address', 'value'=>$street_address, 'type'=>'string'),
                               array('fieldName'=>'entry_postcode', 'value'=>$postcode, 'type'=>'string'),
                               array('fieldName'=>'entry_city', 'value'=>$city, 'type'=>'string'),
                               array('fieldName'=>'entry_country_id', 'value'=>$country, 'type'=>'integer'));
    
        if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'entry_gender', 'value'=>$gender, 'type'=>'enum:m|f');
        if (ACCOUNT_COMPANY == 'true') $sql_data_array[] = array('fieldName'=>'entry_company', 'value'=>$company, 'type'=>'string');
        if (ACCOUNT_SUBURB == 'true') $sql_data_array[] = array('fieldName'=>'entry_suburb', 'value'=>$suburb, 'type'=>'string');
        if (ACCOUNT_STATE == 'true') {
          if ($zone_id > 0) {
            $sql_data_array[] = array('fieldName'=>'entry_zone_id', 'value'=>$zone_id, 'type'=>'integer');
            $sql_data_array[] = array('fieldName'=>'entry_state', 'value'=>'', 'type'=>'string');
          } else {
            $sql_data_array[] = array('fieldName'=>'entry_zone_id', 'value'=>'0', 'type'=>'integer');
            $sql_data_array[] = array('fieldName'=>'entry_state', 'value'=>$state, 'type'=>'string');
          }
        }
    
        if ($_POST['action'] == 'update') {
          $where_clause = "address_book_id = :edit and customers_id = :customersID";
          $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
          $where_clause = $db->bindVars($where_clause, ':edit', $_GET['edit'], 'integer');
          $db->perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', $where_clause);
    
          $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_ENTRY_UPDATE_DONE');
    
          // re-register session variables
          if ( (isset($_POST['primary']) && ($_POST['primary'] == 'on')) || ($_GET['edit'] == $_SESSION['customer_default_address_id']) ) {
            $_SESSION['customer_first_name'] = $firstname;
            $_SESSION['customer_country_id'] = $country;
            $_SESSION['customer_zone_id'] = (($zone_id > 0) ? (int)$zone_id : '0');
            $_SESSION['customer_default_address_id'] = (int)$_GET['edit'];
    
            $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'string'),
                                    array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'string'),
                                    array('fieldName'=>'customers_default_address_id', 'value'=>$_GET['edit'], 'type'=>'integer'));
    
            if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'customers_gender', 'value'=>$gender, 'type'=>'enum:m|f');
            $where_clause = "customers_id = :customersID";
            $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
            $db->perform(TABLE_CUSTOMERS, $sql_data_array, 'update', $where_clause);
          }
        } else {
    
          $sql_data_array[] = array('fieldName'=>'customers_id', 'value'=>$_SESSION['customer_id'], 'type'=>'integer');
    //      print_r($sql_data_array);
          $db->perform(TABLE_ADDRESS_BOOK, $sql_data_array);
    
          $new_address_book_id = $db->Insert_ID();
    
          $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_ADD_ENTRY_DONE');
    
          // reregister session variables
          if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) {
            $_SESSION['customer_first_name'] = $firstname;
            $_SESSION['customer_country_id'] = $country;
            $_SESSION['customer_zone_id'] = (($zone_id > 0) ? (int)$zone_id : '0');
            if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) $_SESSION['customer_default_address_id'] = $new_address_book_id;
    
            $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'string'),
                                    array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'string'));
    
            if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'customers_gender', 'value'=>$gender, 'type'=>'string');
            if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) $sql_data_array[] = array('fieldName'=>'customers_default_address_id', 'value'=>$new_address_book_id, 'type'=>'integer');
    
            $where_clause = "customers_id = :customersID";
            $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
            $db->perform(TABLE_CUSTOMERS, $sql_data_array, 'update', $where_clause);
          }
        }
    
        $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
    }
    
    if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
      $entry_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 = :customersID
                      AND    address_book_id = :addressBookID";
    
      $entry_query = $db->bindVars($entry_query, ':customersID', $_SESSION['customer_id'], 'integer');
      $entry_query = $db->bindVars($entry_query, ':addressBookID', $_GET['edit'], 'integer');
      $entry = $db->Execute($entry_query);
    
      if ($entry->RecordCount()<=0) {
        $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
      if (!isset($zone_name) || (int)$zone_name == 0) $zone_name = zen_get_zone_name($entry->fields['entry_country_id'], $entry->fields['entry_zone_id'], $entry->fields['entry_state']);
      if (!isset($zone_id) || (int)$zone_id == 0) $zone_id = $entry->fields['entry_zone_id'];
    
    } elseif (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      if ($_GET['delete'] == $_SESSION['customer_default_address_id']) {
        $messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      } else {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ADDRESS_BOOK . "
                        WHERE address_book_id = :addressBookID
                        AND customers_id = :customersID";
    
        $check_query = $db->bindVars($check_query, ':customersID', $_SESSION['customer_id'], 'integer');
        $check_query = $db->bindVars($check_query, ':addressBookID', $_GET['delete'], 'integer');
        $check = $db->Execute($check_query);
    
        if ($check->fields['total'] < 1) {
          $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);
    
          zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
        }
      }
    } else {
      $entry_query = "SELECT entry_country_id
                      FROM   " . TABLE_ADDRESS_BOOK . " a, " . TABLE_CUSTOMERS . " c
                      WHERE  a.customers_id = :customersID
                      AND  a.customers_id = c.customers_id
                      AND    a.address_book_id = c.customers_default_address_id";
    
      $entry_query = $db->bindVars($entry_query, ':customersID', $_SESSION['customer_id'], 'integer');
      $entry = $db->Execute($entry_query);
    }
    /*
     * Set flags for template use:
     */
      $selected_country = (isset($_POST['zone_country_id']) && $_POST['zone_country_id'] != '') ? $country : SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
      if ($process == true) $entry->fields['entry_country_id'] = $selected_country; 
      $flag_show_pulldown_states = ((($process == true || $entry_state_has_zones == true) && $zone_name == '') || ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true' || $error_state_input) ? true : false;
      $state = ($flag_show_pulldown_states) ? $state : $zone_name;
      $state_field_label = ($flag_show_pulldown_states) ? '' : ENTRY_STATE;
    
    
    
    if (!isset($_GET['delete']) && !isset($_GET['edit'])) {
      if (zen_count_customer_address_book_entries() >= MAX_ADDRESS_BOOK_ENTRIES) {
        $messageStack->add_session('addressbook', ERROR_ADDRESS_BOOK_FULL);
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
    }
    
    $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
    $breadcrumb->add(NAVBAR_TITLE_2, zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
    
    if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
      $breadcrumb->add(NAVBAR_TITLE_MODIFY_ENTRY);
    } elseif (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      $breadcrumb->add(NAVBAR_TITLE_DELETE_ENTRY);
    } else {
      $breadcrumb->add(NAVBAR_TITLE_ADD_ENTRY);
    }
    
    // This should be last line of the script:
    $zco_notifier->notify('NOTIFY_HEADER_END_ADDRESS_BOOK_PROCESS');
    ?>

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Update Address Book Entry- not updating

    Have *you* compared the file against the original version (you said you're running v1.3.7.1, so compare against original 1.3.7.1 file) to see if there are any differences?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jun 2007
    Location
    TN
    Posts
    83
    Plugin Contributions
    0

    Default Re: Update Address Book Entry- not updating

    My husband built the site and modded it. I have no idea what he has done. I am just trying to fix things here and there as I find them. We are not the owners. I am just an admin on commission.

    I did fix the lightbox problem after many frustrating days!

    As far as this problem goes, I need someone more experienced to look at it for me.

    I am posting the oldest file here, so I will assume it is the original unless he deleted the original.

    Code:
    <?php
    /**
     * Header code file for the Address Book Process page
     *
     * @package page
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: header_php.php 4824 2006-10-23 21:01:28Z drbyte $
     */
    // This should be first line of the script:
    $zco_notifier->notify('NOTIFY_HEADER_START_ADDRESS_BOOK_PROCESS');
    
    if (!$_SESSION['customer_id']) {
      $_SESSION['navigation']->set_snapshot();
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
    
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    
    /**
     * Process deletes
     */
    if (isset($_GET['action']) && ($_GET['action'] == 'deleteconfirm') && isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      $sql = "DELETE FROM " . TABLE_ADDRESS_BOOK . "
              WHERE  address_book_id = :delete 
              AND    customers_id = :customersID";
    
      $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
      $sql = $db->bindVars($sql, ':delete', $_GET['delete'], 'integer');
      $db->Execute($sql);
    
      $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_DELETION_DONE');
    
      $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success');
    
      zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
    }
    
    /**
     * Set some defaults
     */
      $process = false;
      $zone_name = '';
      $entry_state_has_zones = '';
      $error_state_input = false;
      $state = '';
      $zone_id = 0;
      $error = false;
    /**
     * Process new/update actions
     */
    if (isset($_POST['action']) && (($_POST['action'] == 'process') || ($_POST['action'] == 'update'))) {
      $process = true;
    
      if (ACCOUNT_GENDER == 'true') $gender = zen_db_prepare_input($_POST['gender']);
      if (ACCOUNT_COMPANY == 'true') $company = zen_db_prepare_input($_POST['company']);
      $firstname = zen_db_prepare_input($_POST['firstname']);
      $lastname = zen_db_prepare_input($_POST['lastname']);
      $street_address = zen_db_prepare_input($_POST['street_address']);
      if (ACCOUNT_SUBURB == 'true') $suburb = zen_db_prepare_input($_POST['suburb']);
      $postcode = zen_db_prepare_input($_POST['postcode']);
      $city = zen_db_prepare_input($_POST['city']);
    
    
      /**
         * error checking when updating or adding an entry
         */
      if (ACCOUNT_STATE == 'true') {
        $state = zen_db_prepare_input($_POST['state']);
        if (isset($_POST['zone_id'])) {
          $zone_id = zen_db_prepare_input($_POST['zone_id']);
        } else {
          $zone_id = false;
        }
      }
      $country = zen_db_prepare_input($_POST['zone_country_id']);
      //echo ' I SEE: country=' . $country . '&nbsp;&nbsp;&nbsp;state=' . $state . '&nbsp;&nbsp;&nbsp;zone_id=' . $zone_id;
    
      if (ACCOUNT_GENDER == 'true') {
        if ( ($gender != 'm') && ($gender != 'f') ) {
          $error = true;
          $messageStack->add('addressbook', ENTRY_GENDER_ERROR);
        }
      }
    
      if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_FIRST_NAME_ERROR);
      }
    
      if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_LAST_NAME_ERROR);
      }
    
      if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_STREET_ADDRESS_ERROR);
      }
    
      if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_CITY_ERROR);
      }
    
      if (ACCOUNT_STATE == 'true') {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ZONES . "
                        WHERE zone_country_id = :zoneCountryID";
        $check_query = $db->bindVars($check_query, ':zoneCountryID', $country, 'integer');
        $check = $db->Execute($check_query);
        $entry_state_has_zones = ($check->fields['total'] > 0);
        if ($entry_state_has_zones == true) {
          $zone_query = "SELECT distinct zone_id, zone_name, zone_code
                         FROM " . TABLE_ZONES . "
                         WHERE zone_country_id = :zoneCountryID
                         AND " . 
                         ((trim($state) != '' && $zone_id == 0) ? "(upper(zone_name) like ':zoneState%' OR upper(zone_code) like '%:zoneState%') OR " : "") .
                        "zone_id = :zoneID
                         ORDER BY zone_code ASC, zone_name";
    
          $zone_query = $db->bindVars($zone_query, ':zoneCountryID', $country, 'integer');
          $zone_query = $db->bindVars($zone_query, ':zoneState', strtoupper($state), 'noquotestring');
          $zone_query = $db->bindVars($zone_query, ':zoneID', $zone_id, 'integer');
          $zone = $db->Execute($zone_query);
    
          //look for an exact match on zone ISO code
          $found_exact_iso_match = ($zone->RecordCount() == 1);
          if ($zone->RecordCount() > 1) {
            while (!$zone->EOF && !$found_exact_iso_match) {
              if (strtoupper($zone->fields['zone_code']) == strtoupper($state) ) {
                $found_exact_iso_match = true;
                continue;
              }
              $zone->MoveNext();
            }
          }
    
          if ($found_exact_iso_match) {
            $zone_id = $zone->fields['zone_id'];
            $zone_name = $zone->fields['zone_name'];
          } else {
            $error = true;
            $error_state_input = true;
            $messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT);
          }
        } else {
          if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
            $error = true;
            $error_state_input = true;
            $messageStack->add('addressbook', ENTRY_STATE_ERROR);
          }
        }
      }
    
      if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_POST_CODE_ERROR);
      }
    
      if (!is_numeric($country)) {
        $error = true;
        $messageStack->add('addressbook', ENTRY_COUNTRY_ERROR);
      }
    
      if ($error == false) {
        $sql_data_array= array(array('fieldName'=>'entry_firstname', 'value'=>$firstname, 'type'=>'string'),
                               array('fieldName'=>'entry_lastname', 'value'=>$lastname, 'type'=>'string'),
                               array('fieldName'=>'entry_street_address', 'value'=>$street_address, 'type'=>'string'),
                               array('fieldName'=>'entry_postcode', 'value'=>$postcode, 'type'=>'string'),
                               array('fieldName'=>'entry_city', 'value'=>$city, 'type'=>'string'),
                               array('fieldName'=>'entry_country_id', 'value'=>$country, 'type'=>'integer'));
    
        if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'entry_gender', 'value'=>$gender, 'type'=>'enum:m|f');
        if (ACCOUNT_COMPANY == 'true') $sql_data_array[] = array('fieldName'=>'entry_company', 'value'=>$company, 'type'=>'string');
        if (ACCOUNT_SUBURB == 'true') $sql_data_array[] = array('fieldName'=>'entry_suburb', 'value'=>$suburb, 'type'=>'string');
        if (ACCOUNT_STATE == 'true') {
          if ($zone_id > 0) {
            $sql_data_array[] = array('fieldName'=>'entry_zone_id', 'value'=>$zone_id, 'type'=>'integer');
            $sql_data_array[] = array('fieldName'=>'entry_state', 'value'=>'', 'type'=>'string');
          } else {
            $sql_data_array[] = array('fieldName'=>'entry_zone_id', 'value'=>'0', 'type'=>'integer');
            $sql_data_array[] = array('fieldName'=>'entry_state', 'value'=>$state, 'type'=>'string');
          }
        }
    
        if ($_POST['action'] == 'update') {
          $where_clause = "address_book_id = :edit and customers_id = :customersID";
          $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
          $where_clause = $db->bindVars($where_clause, ':edit', $_GET['edit'], 'integer');
          $db->perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', $where_clause);
    
          $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_ENTRY_UPDATE_DONE');
    
          // re-register session variables
          if ( (isset($_POST['primary']) && ($_POST['primary'] == 'on')) || ($_GET['edit'] == $_SESSION['customer_default_address_id']) ) {
            $_SESSION['customer_first_name'] = $firstname;
            $_SESSION['customer_country_id'] = $country;
            $_SESSION['customer_zone_id'] = (($zone_id > 0) ? (int)$zone_id : '0');
            $_SESSION['customer_default_address_id'] = (int)$_GET['edit'];
    
            $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'string'),
                                    array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'string'),
                                    array('fieldName'=>'customers_default_address_id', 'value'=>$_GET['edit'], 'type'=>'integer'));
    
            if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'customers_gender', 'value'=>$gender, 'type'=>'enum:m|f');
            $where_clause = "customers_id = :customersID";
            $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
            $db->perform(TABLE_CUSTOMERS, $sql_data_array, 'update', $where_clause);
          }
        } else {
    
          $sql_data_array[] = array('fieldName'=>'customers_id', 'value'=>$_SESSION['customer_id'], 'type'=>'integer');
    //      print_r($sql_data_array);
          $db->perform(TABLE_ADDRESS_BOOK, $sql_data_array);
    
          $new_address_book_id = $db->Insert_ID();
    
          $zco_notifier->notify('NOTIFY_HEADER_ADDRESS_BOOK_ADD_ENTRY_DONE');
    
          // reregister session variables
          if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) {
            $_SESSION['customer_first_name'] = $firstname;
            $_SESSION['customer_country_id'] = $country;
            $_SESSION['customer_zone_id'] = (($zone_id > 0) ? (int)$zone_id : '0');
            if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) $_SESSION['customer_default_address_id'] = $new_address_book_id;
    
            $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'string'),
                                    array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'string'));
    
            if (ACCOUNT_GENDER == 'true') $sql_data_array[] = array('fieldName'=>'customers_gender', 'value'=>$gender, 'type'=>'string');
            if (isset($_POST['primary']) && ($_POST['primary'] == 'on')) $sql_data_array[] = array('fieldName'=>'customers_default_address_id', 'value'=>$new_address_book_id, 'type'=>'integer');
    
            $where_clause = "customers_id = :customersID";
            $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
            $db->perform(TABLE_CUSTOMERS, $sql_data_array, 'update', $where_clause);
          }
        }
    
        $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
    }
    
    if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
      $entry_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 = :customersID
                      AND    address_book_id = :addressBookID";
    
      $entry_query = $db->bindVars($entry_query, ':customersID', $_SESSION['customer_id'], 'integer');
      $entry_query = $db->bindVars($entry_query, ':addressBookID', $_GET['edit'], 'integer');
      $entry = $db->Execute($entry_query);
    
      if ($entry->RecordCount()<=0) {
        $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
      if (!isset($zone_name) || (int)$zone_name == 0) $zone_name = zen_get_zone_name($entry->fields['entry_country_id'], $entry->fields['entry_zone_id'], $entry->fields['entry_state']);
      if (!isset($zone_id) || (int)$zone_id == 0) $zone_id = $entry->fields['entry_zone_id'];
    
    } elseif (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      if ($_GET['delete'] == $_SESSION['customer_default_address_id']) {
        $messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');
    
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      } else {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ADDRESS_BOOK . "
                        WHERE address_book_id = :addressBookID
                        AND customers_id = :customersID";
    
        $check_query = $db->bindVars($check_query, ':customersID', $_SESSION['customer_id'], 'integer');
        $check_query = $db->bindVars($check_query, ':addressBookID', $_GET['delete'], 'integer');
        $check = $db->Execute($check_query);
    
        if ($check->fields['total'] < 1) {
          $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);
    
          zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
        }
      }
    } else {
      $entry_query = "SELECT entry_country_id
                      FROM   " . TABLE_ADDRESS_BOOK . " a, " . TABLE_CUSTOMERS . " c
                      WHERE  a.customers_id = :customersID
                      AND  a.customers_id = c.customers_id
                      AND    a.address_book_id = c.customers_default_address_id";
    
      $entry_query = $db->bindVars($entry_query, ':customersID', $_SESSION['customer_id'], 'integer');
      $entry = $db->Execute($entry_query);
    }
    /*
     * Set flags for template use:
     */
      $selected_country = (isset($_POST['zone_country_id']) && $_POST['zone_country_id'] != '') ? $country : SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
      if ($process == true) $entry->fields['entry_country_id'] = $selected_country; 
      $flag_show_pulldown_states = ((($process == true || $entry_state_has_zones == true) && $zone_name == '') || ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true' || $error_state_input) ? true : false;
      $state = ($flag_show_pulldown_states) ? $state : $zone_name;
      $state_field_label = ($flag_show_pulldown_states) ? '' : ENTRY_STATE;
    
    
    
    if (!isset($_GET['delete']) && !isset($_GET['edit'])) {
      if (zen_count_customer_address_book_entries() >= MAX_ADDRESS_BOOK_ENTRIES) {
        $messageStack->add_session('addressbook', ERROR_ADDRESS_BOOK_FULL);
        zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
      }
    }
    
    $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
    $breadcrumb->add(NAVBAR_TITLE_2, zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
    
    if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
      $breadcrumb->add(NAVBAR_TITLE_MODIFY_ENTRY);
    } elseif (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
      $breadcrumb->add(NAVBAR_TITLE_DELETE_ENTRY);
    } else {
      $breadcrumb->add(NAVBAR_TITLE_ADD_ENTRY);
    }
    
    // This should be last line of the script:
    $zco_notifier->notify('NOTIFY_HEADER_END_ADDRESS_BOOK_PROCESS');
    ?>

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Update Address Book Entry- not updating

    So, basically, you're asking someone else to do what you could do for yourself ... ?

    1. Download the original 1.3.7.1 fileset from SourceForge (see link on zen-cart.com home page)
    2. Unzip it.
    3. Use WinMerge to compare that particular file from *your* server against the original v1.3.7.1 file.
    4. Note any differences and whether those differences may pertain to certain addons you've installed.
    If you can't figure out why a particular difference exists, then post it to the forum with an explanation of what's going "wrong" (such as you've described above).
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Jun 2007
    Location
    TN
    Posts
    83
    Plugin Contributions
    0

    Default Re: Update Address Book Entry- not updating

    Can you post a link here? Maybe I am just an idiot, but I cannot find a place on Zencart home page with a link to this fileset. I just saw a place for 1.3.8. I went to sourceforge and searched and only found mods and languages and 1.3.8. Too tired too think and I just got home from the hospital from 15th spinal tap......not feeling all that spiffy. Please, help me out here.

  8. #8
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Update Address Book Entry- not updating

    The link on the Zen Cart home page points to the following page on Sourceforge, which handles ALL the 1.3.x series, including the v1.3.8 that's mentioned next to the button on the home page: http://sourceforge.net/project/showf...kage_id=171544

    On that screen you'll see all the v1.3.x releases. Click on the 1.3.7 release, and then choose the 1.3.7.1 full zip.


    While you're doing the comparisons, it might be prudent to do an entire compare on all your files, in case the problem lies elsewhere.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Jun 2007
    Location
    TN
    Posts
    83
    Plugin Contributions
    0

    Default Re: Update Address Book Entry- not updating

    I found line 209 was different. It had an extra );
    I replaced that line with the original line of code, but the error still occurs.

    There are two tax id add-ons in there that my husband has added because the site is wholesale and only retailers can log in. I have no idea if they would have affected the address book. I tried removing the lines from the code and the error still occurred. I don't get it.

  10. #10
    Join Date
    Sep 2004
    Location
    Murfreesboro, TN
    Posts
    588
    Plugin Contributions
    0

    Default Re: Update Address Book Entry- not updating

    As the Ms. said, I am the one that changed the code, and yes, it was my fault. It was the tax id writing back to the create account field. I removed that part of the code from the address book update and everything seems to work.

    Thanks Dr. Byte, and your track record still remains impeccable (IMHO). Can't wait to do this all again someday when my wife's employer will cough up the money to do the upgrade and get off the old code. I also hope the new code will have a field to implement tax id or tracking wholesalers and I won't have to do hacks like this anymore

    Sincerely,

    0be1
    "Give me one hundred preachers who fear nothing but sin and desire nothing but God, and I care not whether they be clergymen or laymen, they alone will shake the gates of Hell and set up the kingdom of Heaven upon Earth." - John Wesley

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Users unable to update Address Book Entry
    By mick9876 in forum General Questions
    Replies: 5
    Last Post: 22 Nov 2011, 02:20 PM
  2. Replies: 8
    Last Post: 1 Apr 2009, 05:26 PM
  3. Change Address Book Entry Format?
    By panqueconpasas in forum General Questions
    Replies: 1
    Last Post: 5 Oct 2007, 06:05 AM
  4. IE6 Syntax errors on 'Update Address Book Entry' page
    By efghijk in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 19 Jul 2007, 07:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR