From f0dde5e98304f28d74df86d480cf053d3cdc0d4e Mon Sep 17 00:00:00 2001 From: fBrignoli Date: Wed, 21 Sep 2011 15:49:43 +0000 Subject: [PATCH] // missing file in previous commit git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8701 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Address.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/classes/Address.php b/classes/Address.php index 7cf3c116c..83e83b7d7 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -311,5 +311,32 @@ class AddressCore extends ObjectModel WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '') ); } + + /** + * Initiliaze an address corresponding to the specified id address or if empty to the + * default shop configuration + * + * @param int $id_address + * @return Address address + */ + public static function initialize($id_address = null) + { + // set the default address + $address = new Address(); + $address->id_country = (int)Context::getContext()->country->id; + $address->id_state = 0; + $address->postcode = 0; + + // if an id_address has been specified retrieve the address + if ($id_address) + { + $address = new Address((int)$id_address); + + if (!Validate::isLoadedObject($address)) + throw new Exception('Invalid address'); + } + + return $address; + } }