Index: openacs-4/packages/ecommerce/www/address-international.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/address-international.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/ecommerce/www/address-international.tcl 10 Dec 2002 20:06:18 -0000 1.6 +++ openacs-4/packages/ecommerce/www/address-international.tcl 13 Jan 2005 13:57:57 -0000 1.7 @@ -19,7 +19,7 @@ # we need them to be logged in -set user_id [ad_verify_and_get_user_id] +set user_id [ad_conn user_id] if {$user_id == 0} { set return_url "[ad_conn url]" ad_returnredirect "/register?[export_url_vars return_url]" @@ -34,20 +34,48 @@ # Retrieve the saved address with address_id. if { [info exists address_id] } { - db_0or1row shipping_address " - select * + db_0or1row select_address " + select attn, line1, line2, city, usps_abbrev, zip_code, phone, country_code, full_state_name, phone_time from ec_addresses where address_id=:address_id" set country_widget [ec_country_widget $country_code] } else { set country_widget [ec_country_widget] - set attn [ad_quotehtml [db_string get_full_name " - select first_names || ' ' || last_name as name - from cc_users - where user_id=:user_id"]] + # Retrieve the default name. + + # get the separate fields for card processing + db_0or1row get_names " + select first_names, last_name + from cc_users + where user_id=:user_id" + # we could use a single name field for shipping + # but shipping address becomes default for billing! + # attn has a 3 space delimiter for parsing last/first names + + # set attn just in case it gets used + # avoid using it for single field name entry. + set attn "$first_names $last_name" + } +# set the defaults for name fields if they are empty +if {[info exists last_name] != 1} { + if {[info exists attn]} { + # delimiter is triple space (for parsing). + set name_delim [string first " " $attn] + if {$name_delim < 0 } { + set name_delim 0 + } + set first_names [string trim [string range $attn 0 $name_delim]] + set last_name [string range $attn [expr $name_delim + 3 ] end] + } +} +set user_last_name_with_quotes_escaped [ad_quotehtml $last_name] +set user_first_names_with_quotes_escaped [ad_quotehtml $first_names] + +set user_name_with_quotes_escaped [ad_quotehtml $attn] + # Get the form vars that were passed on delete-address so that they # can be passed back to the calling url. gift-certificate-billing has # a bunch of form vars that should not be lost.