Re: Re: Storing Address information in User Profile

Posts: 41
Joined: 09/07/2007

I did some digging into the Ubercart modules today and have a better understanding of how address data is stored and how it could work with user profiles.

My Observations (correct me if I'm wrong)
1. There is currently only one place that pulls old address data for use in the future. This is in the /cart/checkout form under the "Saved Addresses:" field. It does a database query on "uc_orders" for each unique address that a user has used in the past. That query is in the uc_get_addresses() function in uc_store.module.

2. Editing an order pulls the address info from the table "uc_orders" with the function uc_order_load() in uc_order.module.

My Proposal
1. I would like to create a module that adds a table "uc_user_addresses" to the database and contains a function uc_add_user_address() that will save an address to this table when an order is submitted.

2. The "uc_user_addresses" table would contain the same address info like "delivery_" and "billing_". It could also contain a "save_as" column that could be used to save multiple addressed like "Home", "Work", etc.

3. The module would only allow a single address per "save_as" type per user. Currently with the uc_get_addresses() function, you can have multiple addresses that could refer to the same location if they submit a second order and type in their address with a slight variation. For example, if it was "123 55th Ter." and they changed it to "123 55th Terr" when they submitted a second order.

4. In the check out form, add a "Save Address As:" drop down with a few "save_as" types.

5. Change the uc_get_addresses() function to use an if() statement to pull addressed from the new "uc_user_addresses" table if it exists, else, do the current query on the "uc_orders" table to provide backwards compatibility. This should allow the "Saved Addresses:" drop down on the /cart/checkout form to populate with either the new "uc_user_addresses" data or the "uc_orders" history data.

6. Add "Temporary Change" and "Permanent Change" radios to the /admin/store/orders/1/edit form. "Temporary Change" only updates the "uc_orders" table. "Permanent Change" updates both the "uc_orders" table and the "uc_user_addresses" table.

What do you think about this? It doesn't seem as hard as I thought it would be now that I've got it outlined. Although, I've never created a module before, but what better time to start then now?

Storing Address information in User Profile By: bendiy (74 replies) Thu, 10/25/2007 - 19:04