Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2008
    Posts
    21
    Plugin Contributions
    0

    Default address format different on checkout page vs address book

    Zen Cart 1.3.8a from clean install.

    The address formats are different on the address book page vs the change shipping or change billing address pages.

    On the address book page, they are displaying in the correct format (address_format_id 2 for US addresses, etc from the address_format table). But when checking out, on the change shipping or change billing address pages, these same addresses are all displaying with a format of 1 no matter the country.

    The files tpl_modules_checkout_address_book.php and tpl_address_book_default.php have not been changed from the original install.

    Why is the checkout address book not displaying the address in the proper format?

    I'm not an expert at php, but this is what I see in those files.

    In tpl_address_book_default.php, the code that displays the addresses in the correct format:
    Code:
    <?php
    /**
     * Used to loop thru and display address book entries
     */
      foreach ($addressArray as $addresses) {
    ?>
    <h3 class="addressBookDefaultName"><?php echo zen_output_string_protected($addresses['firstname'] . ' ' . $addresses['lastname']); ?><?php if ($addresses['address_book_id'] == $_SESSION['customer_default_address_id']) echo '&nbsp;' . PRIMARY_ADDRESS ; ?></h3>
    
    <address><?php echo zen_address_format($addresses['format_id'], $addresses['address'], true, ' ', '<br />'); ?></address>
    
    <div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'edit=' . $addresses['address_book_id'], 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT) . '</a> <a href="' . zen_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'delete=' . $addresses['address_book_id'], 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_DELETE_SMALL, BUTTON_DELETE_SMALL_ALT) . '</a>'; ?></div>
    <br class="clearBoth" />
    <?php
      }
    ?>
    In the code for the file tpl_modules_checkout_address_book.php, which is not displaying the addresses correctly:
    Code:
    <?php
    /**
     * require code to get address book details
     */
      require(DIR_WS_MODULES . zen_get_module_directory('checkout_address_book.php'));
    ?>
    
    <?php
          while (!$addresses->EOF) {
            if ($addresses->fields['address_book_id'] == $_SESSION['sendto']) {
              echo '      <div id="defaultSelected" class="moduleRowSelected">' . "\n";
            } else {
              echo '      <div class="moduleRow">' . "\n";
            }
    ?>
            <div class="back"><?php echo zen_draw_radio_field('address', $addresses->fields['address_book_id'], ($addresses->fields['address_book_id'] == $_SESSION['sendto']), 'id="name-' . $addresses->fields['address_book_id'] . '"'); ?></div>
            <div class="back"><label for="name-<?php echo $addresses->fields['address_book_id']; ?>"><?php echo zen_output_string_protected($addresses->fields['firstname'] . ' ' . $addresses->fields['lastname']); ?></label></div>
          </div>
          <br class="clearBoth" />
           <address><?php echo zen_address_format($format_id, $addresses->fields, true, ' ', '<br />'); ?></address>
    
    <?php
            $addresses->MoveNext();
          }
    ?>
    Again, these files are the same as the original install files. How can I make the checkout addresses display in the correct format?

    Thanks!
    Melissa

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

    Default Re: address format different on checkout page vs address book

    Quote Originally Posted by ladyhypnotist View Post
    In the code for the file tpl_modules_checkout_address_book.php, which is not displaying the addresses correctly:
    Code:
           <address><?php echo zen_address_format($format_id, $addresses->fields, true, ' ', '<br />'); ?></address>
    It seems to be using the format for the "last" address in the list, and applying that to all the addresses it's displaying.
    What if you change $format_id, as shown?:
    Code:
      <address><?php echo zen_address_format(zen_get_address_format_id($addresses->fields['country_id']), $addresses->fields, true, ' ', '<br />'); ?></address>
    .

    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
    Sep 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: address format different on checkout page vs address book

    I changed the code as you suggested, and it fixed it the problem with the addresses not formatting with the correct country format. Thanks!

 

 

Similar Threads

  1. Replies: 9
    Last Post: 7 May 2016, 06:39 PM
  2. How can I stop requiring address on address book page?
    By jaredt112 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Apr 2010, 02:30 AM
  3. Move Address Book entries on Shipping Address page
    By giftmeister in forum Basic Configuration
    Replies: 0
    Last Post: 17 May 2009, 07:30 PM
  4. Change Address Book Entry Format?
    By panqueconpasas in forum General Questions
    Replies: 1
    Last Post: 5 Oct 2007, 06:05 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