Spree::Address
model is used to track address information, mainly for orders. Address information can also be tied to the Spree.user_class
which by default is Spree::User
(More on Users).
Addresses have the following attributes:
Name | Description | Example Value |
---|---|---|
firstname | The first name for the person at this address. | John |
lastname | The last name for the person at this address. | Doe |
address1 | The address’s first line. | 123 Main St |
address2 | (Optional) The address’s second line. | Apt 4 |
city | The city where the address is. | Springfield |
zipcode | The postal code. | 12345 |
phone | The phone number. | (123) 456-7890 |
state_name | The name for the state. | California |
alternative_phone | (Optional) The alternative phone number. | (098) 765-4321 |
company | (Optional) A company name. | Acme Corporation |
country_id | The ID for the country. | 1 |
state_id | (Optional) The ID for the state. | 2 |
user_id | (Optional) The ID of the user this address is associated with. | 10 |
label | (Optional) A label to identify the address. | Home |
Spree::Country
object. It can optionally link to a Spree::State
object, but only in the cases where the related country has no states listed. In that case, the state information is still required, and is kept within the state_name
field on the address record. An easy way to get the state information for the address is to call state_text
on that object.Spree::User
can have multiple addresses and can manage them on the Checkout and Account page (or via API). Each Spree::Address
object has a user_id
column which links to the User.
Additionally in the Spree::User
there is ship_address_id
and bill_address_id
columns which indicates which addresses are the default ones for this User.
Spree::Country
model includes these attributes:
Name | Description | Example Value |
---|---|---|
iso_name | The ISO 3166-1 alpha-2 code for the country. | US |
iso | The ISO 3166-1 alpha-3 code for the country. | USA |
iso_numeric | The ISO 3166-1 numeric code for the country. | 840 |
name | The name of the country. | United States |