Address Book

### Index Up << >>

## Address Book

address_book is a shipping address book. The shipping address book saves information relevant to shipping the order. In its simplest form, this can be the only address book needed. By default these form values are included:

       s_nickname
       name
       fname
       lname
       address
       address1
       address2
       address3
       city
       state
       zip
       country
       phone_day
       mv_shipmode

The first field is always the name of the form variable that contains the key for the entry.

The values are saved with the `[userdb function=set_shipping]` tag call, and are recalled with `[userdb function=get_shipping]`. A list of the keys available is kept in the form value `address_book`, suitable for iteration in an HTML select box or in a set of links.

You can get the names of a the addresses with the get_shipping_names function:

        [userdb function=get_shipping_names]

By default, they are placed in the variable `address_book`. Here is a little snippet that builds a select box:

        <FORM ACTION="[process-target]" METHOD=POST>
        [userdb function=get_shipping_names]
        [if value address_book]
        <SELECT NAME="s_nickname">
        [loop arg="[value address_book]"] <OPTION> [loop-code] [/loop]
        </SELECT>
        <INPUT TYPE=submit NAME=mv_check VALUE="Recall Shipping">
        </FORM>

The same principle works with accounts , carts, and preferences.

To restore a cart based on the above, you can place in an `mv_check` routine:

        [set Recall Shipping]
        mv_todo=return
        mv_nextpage=ord/basket
        [userdb function=get_shipping nickname="[value s_nickname]"]
        [/set]

When the mv_check variable is encountered, the contents of the scratch variable `Recall Shipping` are processed and the shipping address information inserted into the user form values. This is destructive of any current values of those user session variables, of course.

If you want to change the fields that are recalled or saved, you can use the shipping parameter:

        [userdb function=get_shipping
                nickname=city_and_state
                shipping="city state"]

Only the values of the `city` and state variables will be replaced.

### Index Up << >>