Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Call Any Address Variable of Current Customer


1 reply to this topic

#1 shawn84

  • Community Member
  • 2 posts
  • Real Name:Shawn

Posted 02 September 2010, 13:06

How to use and display an address variable of the current customers default address

This line of code does a database query:

[indent]$address_database_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");[/indent]

Now you want to put all that information into an array so it can be used. This is the code:

[indent]$address_array = tep_db_fetch_array($address_database_query);[/indent]

Now just assign what data field from the array you want to a variable. This is the code:

[indent]$street_address = $address_array['street_address'];[/indent]

Now you will want to display it somewhere. Just echo the new variable containing the data you want. This is the code:

[indent]<?php echo $street_address;?>[/indent]

Thats it. I would have liked to have found this here, rather than spending a couple hours figuring it out... so hence my posting. If it saves someone else an hour or two, then I'll be happy. Hoped it helped.

Peace :D

Edited by shawn84, 02 September 2010, 13:07.


#2 FIMBLE

  • Community Member
  • 6,567 posts
  • Real Name:Nic
  • Gender:Male

Posted 06 September 2010, 07:39

Thats excellent thank you for the tip, however did you know there is already a similar thing in osC "address Format" ?
Sometimes you're the dog and sometimes the lamp post

My Contributions