diff --git a/docs/upgrades/packages-7.9.4/default-shopping-cart-template.wgpkg b/docs/upgrades/packages-7.9.4/default-shopping-cart-template.wgpkg index da35d5d7b..5ea9fc867 100644 Binary files a/docs/upgrades/packages-7.9.4/default-shopping-cart-template.wgpkg and b/docs/upgrades/packages-7.9.4/default-shopping-cart-template.wgpkg differ diff --git a/lib/WebGUI/Shop/AddressBook.pm b/lib/WebGUI/Shop/AddressBook.pm index 063617703..f6ee1b550 100644 --- a/lib/WebGUI/Shop/AddressBook.pm +++ b/lib/WebGUI/Shop/AddressBook.pm @@ -56,6 +56,61 @@ sub addAddress { #------------------------------------------------------------------- +=head2 appendAddressFormVars ( $var, $properties, $prefix ) + +Add template variables for building a form to edit an address to an existing set of template variables. + +=head3 $var + +A hash ref of template variables. + +=head3 $properties + +A hash ref of properties to assign to as default to the form variables. + +=head3 $prefix + +An optional prefix to add to each variable name, and form name. + +=cut + +sub appendAddressFormVars { + my ($self, $var, $prefix, $properties ) = @_; + my $session = $self->session; + $properties ||= {}; + $prefix ||= ''; + $var ||= {}; + for ( qw{ address1 address2 address3 label firstName lastName city state organization } ) { + $var->{ $prefix . $_ . 'Field' } = WebGUI::Form::text( $session, { + name => $prefix . $_, + maxlength => 35, + defaultValue => $properties->{ $_ } + } ); + } + $var->{ $prefix . 'countryField' } = + WebGUI::Form::country( $session,{ + name => $prefix . 'country', + defaultValue => $properties->{ country } + } ); + $var->{ $prefix . 'codeField' } = + WebGUI::Form::zipcode( $session, { + name => $prefix . 'code', + defaultValue => $properties->{ code } + } ); + $var->{ $prefix . 'phoneNumberField' } = + WebGUI::Form::phone( $session, { + name => $prefix . 'phoneNumber', + defaultValue => $properties->{ phoneNumber } + } ); + $var->{ $prefix . 'emailField' } = + WebGUI::Form::email( $session, { + name => $prefix . 'email', + defaultValue => $properties->{ email } + } ); +} + +#------------------------------------------------------------------- + =head2 create ( session, userId ) Constructor. Creates a new address book for this user. @@ -185,58 +240,6 @@ sub getAddresses { #------------------------------------------------------------------- -=head2 getAddressFormVars ( $properties, $prefix ) - -Return a hashref of template variables for building a form to edit an address. - -=head3 $properties - -A hash ref of properties to assign to as default to the form variables. - -=head3 $prefix - -An optional prefix to add to each variable name, and form name. - -=cut - -sub getAddressFormVars { - my ($self, $prefix, $properties ) = @_; - my $session = $self->session; - $properties ||= {}; - $prefix ||= ''; - my $var = {}; - for ( qw{ address1 address2 address3 label firstName lastName city state organization } ) { - $var->{ $prefix . $_ . 'Field' } = WebGUI::Form::text( $session, { - name => $prefix . $_, - maxlength => 35, - defaultValue => $properties->{ $_ } - } ); - } - $var->{ $prefix . 'countryField' } = - WebGUI::Form::country( $session,{ - name => $prefix . 'country', - defaultValue => $properties->{ country } - } ); - $var->{ $prefix . 'codeField' } = - WebGUI::Form::zipcode( $session, { - name => $prefix . 'code', - defaultValue => $properties->{ code } - } ); - $var->{ $prefix . 'phoneNumberField' } = - WebGUI::Form::phone( $session, { - name => $prefix . 'phoneNumber', - defaultValue => $properties->{ phoneNumber } - } ); - $var->{ $prefix . 'emailField' } = - WebGUI::Form::email( $session, { - name => $prefix . 'email', - defaultValue => $properties->{ email } - } ); - return $var; -} - -#------------------------------------------------------------------- - =head2 getDefaultAddress () Returns the default address for this address book if there is one. Otherwise throws a WebGUI::Error::ObjectNotFound exception. diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index 1c6eb5587..9cbcc3cd1 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -901,8 +901,8 @@ sub www_view { else { ##Address form variables my $addressBook = $self->getAddressBook; - %var = (%var, $addressBook->getAddressFormVars('shipping', {})); - %var = (%var, $addressBook->getAddressFormVars('billing', {})); + $addressBook->appendAddressFormVars(\%var, 'shipping_', {}); + $addressBook->appendAddressFormVars(\%var, 'billing_', {}); } # POS variables