The address book API

Last updated on
9 May 2017

With the address book API, you can control addresses used by Ubercart Addresses. With this API you are able to create, load, edit, save and delete addresses. The API consists of three classes:

You can use this API to build your own uc_addresses-like user interface, to manipulate the behaviour of Ubercart Addresses or to import addresses from external sources.

The address book class: UcAddressesAddressBook

The goal of the address book class is to hold a list of addresses that are currently loaded or added during the request. It is designed so that when the address book is asked for the same address twice during one request, it doesn't need to look it up in the database again.
Each instance of the address book class belongs to one user and each user can only have one address book.
Read more about the address book class.

The address class: UcAddressesAddress

This is the main address class used by Ubercart Addresses. It's goal is to provide specific address book features, such as an address nickname and flags for being the default shipping and/or the default billing address.
Each instance is created through the address book, so the address book is able to keep track of all the addresses it contains.
The class extends UcAddressesSchemaAddress (which takes care for setting and getting address fields, see further).
Read more about the address class.

The schema address class: UcAddressesSchemaAddress

This is the base class for addresses. It's goal is to provide functionality for address fields. You can get and set address field values. For this it's connected with the field handler API (explained further). Unlike the UcAddressesAddress class it's not connected with the address book class, which means you *could* use this class if you want to make use of the field handler API and you want to bypass any restrictions implied with UcAddressesAddress (such as having unique nicknames), but in most cases you should not interact with this class directly.
The class doesn't interact with the database itself: this should be done in subclasses (such as UcAddressesAddress).
Read more about the schema address class.