Added first name and last name address options for products.
This commit is contained in:
parent
77aec308c1
commit
2c41d60933
7 changed files with 58 additions and 21 deletions
|
|
@ -30,7 +30,7 @@ my $session = start(); # this line required
|
||||||
|
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
addNewInboxIndexes( $session );
|
addNewInboxIndexes( $session );
|
||||||
|
updateAddressTable( $session );
|
||||||
finish($session); # this line required
|
finish($session); # this line required
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,6 +43,16 @@ finish($session); # this line required
|
||||||
# print "DONE!\n" unless $quiet;
|
# print "DONE!\n" unless $quiet;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Removes the name field and adds a firstName and lastName field
|
||||||
|
sub updateAddressTable{
|
||||||
|
my $session = shift;
|
||||||
|
print "\tUpdating TABLE address... " unless $quiet;
|
||||||
|
$session->db->write("ALTER TABLE 'address' DROP COLUMN 'name';");
|
||||||
|
$session->db->write("ALTER TABLE 'address' ADD COLUMN 'firstName' VARCHAR(35) AFTER 'label', ADD COLUMN 'lastName' VARCHAR(35) AFTER 'firstName';");
|
||||||
|
print "\tDone.\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Add new indexes to the inbox to make millions of messages possible
|
# Add new indexes to the inbox to make millions of messages possible
|
||||||
sub addNewInboxIndexes {
|
sub addNewInboxIndexes {
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ sub view {
|
||||||
$info->text(
|
$info->text(
|
||||||
name => 'name',
|
name => 'name',
|
||||||
label => $i18n->get('name','Shop'),
|
label => $i18n->get('name','Shop'),
|
||||||
defaultValue => (defined $address) ? $address->get("name") : $form->get('name'),
|
defaultValue => (defined $address) ? $address->get("firstName")." ".$address->get('lastName') : $form->get('name'),
|
||||||
);
|
);
|
||||||
$info->text(
|
$info->text(
|
||||||
name => 'organization',
|
name => 'organization',
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ Returns an HTML formatted address for display.
|
||||||
|
|
||||||
sub getHtmlFormatted {
|
sub getHtmlFormatted {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $address = $self->get("name") . "<br />" . $self->get("address1") . "<br />";
|
my $address = $self->get("firstName"). "<br />" .$self->get("lastName") . "<br />" . $self->get("address1") . "<br />";
|
||||||
$address .= $self->get("address2") . "<br />" if ($self->get("address2") ne "");
|
$address .= $self->get("address2") . "<br />" if ($self->get("address2") ne "");
|
||||||
$address .= $self->get("address3") . "<br />" if ($self->get("address3") ne "");
|
$address .= $self->get("address3") . "<br />" if ($self->get("address3") ne "");
|
||||||
$address .= $self->get("city") . ", ";
|
$address .= $self->get("city") . ", ";
|
||||||
|
|
@ -233,7 +233,8 @@ The address book that this address belongs to.
|
||||||
sub update {
|
sub update {
|
||||||
my ($self, $newProperties) = @_;
|
my ($self, $newProperties) = @_;
|
||||||
my $id = id $self;
|
my $id = id $self;
|
||||||
foreach my $field (qw(address1 address2 address3 state code city label name country phoneNumber)) {
|
#foreach my $field (qw(address1 address2 address3 state code city label name country phoneNumber)) {
|
||||||
|
foreach my $field (qw(address1 address2 address3 state code city label firstName lastName country phoneNumber)) {
|
||||||
$properties{$id}{$field} = (exists $newProperties->{$field}) ? $newProperties->{$field} : $properties{$id}{$field};
|
$properties{$id}{$field} = (exists $newProperties->{$field}) ? $newProperties->{$field} : $properties{$id}{$field};
|
||||||
}
|
}
|
||||||
$properties{$id}{addressBookId} = $self->addressBook->getId;
|
$properties{$id}{addressBookId} = $self->addressBook->getId;
|
||||||
|
|
|
||||||
|
|
@ -347,16 +347,28 @@ sub www_editAddress {
|
||||||
.WebGUI::Form::hidden($session, {name=>"addressId", value=>$form->get("addressId")}),
|
.WebGUI::Form::hidden($session, {name=>"addressId", value=>$form->get("addressId")}),
|
||||||
saveButton => WebGUI::Form::submit($session),
|
saveButton => WebGUI::Form::submit($session),
|
||||||
formFooter => WebGUI::Form::formFooter($session),
|
formFooter => WebGUI::Form::formFooter($session),
|
||||||
address1Field => WebGUI::Form::text($session, {name=>"address1", maxlength=>35, defaultValue=>($form->get("address1") || ((defined $address) ? $address->get('address1') : undef))}),
|
address1Field => WebGUI::Form::text($session,
|
||||||
address2Field => WebGUI::Form::text($session, {name=>"address2", maxlength=>35, defaultValue=>($form->get("address2") || ((defined $address) ? $address->get('address2') : undef))}),
|
{name=>"address1", maxlength=>35, defaultValue=>($form->get("address1") || ((defined $address) ? $address->get('address1') : undef))}),
|
||||||
address3Field => WebGUI::Form::text($session, {name=>"address3", maxlength=>35, defaultValue=>($form->get("address3") || ((defined $address) ? $address->get('address3') : undef))}),
|
address2Field => WebGUI::Form::text($session,
|
||||||
labelField => WebGUI::Form::text($session, {name=>"label", maxlength=>35, defaultValue=>($form->get("label") || ((defined $address) ? $address->get('label') : undef))}),
|
{name=>"address2", maxlength=>35, defaultValue=>($form->get("address2") || ((defined $address) ? $address->get('address2') : undef))}),
|
||||||
nameField => WebGUI::Form::text($session, {name=>"name", maxlength=>35, defaultValue=>($form->get("name") || ((defined $address) ? $address->get('name') : undef))}),
|
address3Field => WebGUI::Form::text($session,
|
||||||
cityField => WebGUI::Form::text($session, {name=>"city", maxlength=>35, defaultValue=>($form->get("city") || ((defined $address) ? $address->get('city') : undef))}),
|
{name=>"address3", maxlength=>35, defaultValue=>($form->get("address3") || ((defined $address) ? $address->get('address3') : undef))}),
|
||||||
stateField => WebGUI::Form::text($session, {name=>"state", maxlength=>35, defaultValue=>($form->get("state") || ((defined $address) ? $address->get('state') : undef))}),
|
labelField => WebGUI::Form::text($session,
|
||||||
countryField => WebGUI::Form::country($session, {name=>"country", defaultValue=>($form->get("country") || ((defined $address) ? $address->get('country') : undef))}),
|
{name=>"label", maxlength=>35, defaultValue=>($form->get("label") || ((defined $address) ? $address->get('label') : undef))}),
|
||||||
codeField => WebGUI::Form::zipcode($session, {name=>"code", defaultValue=>($form->get("code") || ((defined $address) ? $address->get('code') : undef))}),
|
firstNameField => WebGUI::Form::text($session,
|
||||||
phoneNumberField => WebGUI::Form::phone($session, {name=>"phoneNumber", defaultValue=>($form->get("phoneNumber") || ((defined $address) ? $address->get('phoneNumber') : undef))}),
|
{name=>"firstName", maxlength=>35, defaultValue=>($form->get("firstName") || ((defined $address) ? $address->get('firstName') : undef))}),
|
||||||
|
lastNameField => WebGUI::Form::text($session,
|
||||||
|
{name=>"lastName", maxlength=>35, defaultValue=>($form->get("lastName") || ((defined $address) ? $address->get('lastName') : undef))}),
|
||||||
|
cityField => WebGUI::Form::text($session,
|
||||||
|
{name=>"city", maxlength=>35, defaultValue=>($form->get("city") || ((defined $address) ? $address->get('city') : undef))}),
|
||||||
|
stateField => WebGUI::Form::text($session,
|
||||||
|
{name=>"state", maxlength=>35, defaultValue=>($form->get("state") || ((defined $address) ? $address->get('state') : undef))}),
|
||||||
|
countryField => WebGUI::Form::country($session,
|
||||||
|
{name=>"country", defaultValue=>($form->get("country") || ((defined $address) ? $address->get('country') : undef))}),
|
||||||
|
codeField => WebGUI::Form::zipcode($session,
|
||||||
|
{name=>"code", defaultValue=>($form->get("code") || ((defined $address) ? $address->get('code') : undef))}),
|
||||||
|
phoneNumberField => WebGUI::Form::phone($session,
|
||||||
|
{name=>"phoneNumber", defaultValue=>($form->get("phoneNumber") || ((defined $address) ? $address->get('phoneNumber') : undef))}),
|
||||||
);
|
);
|
||||||
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("shopAddressTemplateId"));
|
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("shopAddressTemplateId"));
|
||||||
$template->prepare;
|
$template->prepare;
|
||||||
|
|
@ -380,8 +392,11 @@ sub www_editAddressSave {
|
||||||
if ($form->get("label") eq "") {
|
if ($form->get("label") eq "") {
|
||||||
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('label')));
|
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('label')));
|
||||||
}
|
}
|
||||||
if ($form->get("name") eq "") {
|
if ($form->get("firstName") eq "") {
|
||||||
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('name')));
|
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('firstName')));
|
||||||
|
}
|
||||||
|
if ($form->get("lastName") eq "") {
|
||||||
|
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('lastName')));
|
||||||
}
|
}
|
||||||
if ($form->get("address1") eq "") {
|
if ($form->get("address1") eq "") {
|
||||||
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('address')));
|
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $i18n->get('address')));
|
||||||
|
|
@ -400,7 +415,8 @@ sub www_editAddressSave {
|
||||||
}
|
}
|
||||||
my %addressData = (
|
my %addressData = (
|
||||||
label => $form->get("label"),
|
label => $form->get("label"),
|
||||||
name => $form->get("name"),
|
firstName => $form->get("firstName"),
|
||||||
|
lastName => $form->get("lastName"),
|
||||||
address1 => $form->get("address1"),
|
address1 => $form->get("address1"),
|
||||||
address2 => $form->get("address2"),
|
address2 => $form->get("address2"),
|
||||||
address3 => $form->get("address3"),
|
address3 => $form->get("address3"),
|
||||||
|
|
|
||||||
|
|
@ -636,12 +636,12 @@ sub www_getCredentials {
|
||||||
$f->text(
|
$f->text(
|
||||||
-name => 'firstName',
|
-name => 'firstName',
|
||||||
-label => $i18n->get('firstName'),
|
-label => $i18n->get('firstName'),
|
||||||
-value => $form->process("firstName") || $addressData->{ name } || $u->profileField('firstName'),
|
-value => $form->process("firstName") || $addressData->{ "firstName" } || $u->profileField('firstName'),
|
||||||
);
|
);
|
||||||
$f->text(
|
$f->text(
|
||||||
-name => 'lastName',
|
-name => 'lastName',
|
||||||
-label => $i18n->get('lastName'),
|
-label => $i18n->get('lastName'),
|
||||||
-value => $form->process("lastName") || $u->profileField('lastName'),
|
-value => $form->process("lastName") || $addressData->{ "lastName" } || $u->profileField('lastName'),
|
||||||
);
|
);
|
||||||
$f->text(
|
$f->text(
|
||||||
-name => 'address',
|
-name => 'address',
|
||||||
|
|
|
||||||
|
|
@ -593,7 +593,7 @@ sub update {
|
||||||
$newProperties->{taxes} = $cart->calculateTaxes;
|
$newProperties->{taxes} = $cart->calculateTaxes;
|
||||||
my $address = $cart->getShippingAddress;
|
my $address = $cart->getShippingAddress;
|
||||||
$newProperties->{shippingAddressId} = $address->getId;
|
$newProperties->{shippingAddressId} = $address->getId;
|
||||||
$newProperties->{shippingAddressName} = $address->get('name');
|
$newProperties->{shippingAddressName} = $address->get('firstName') . " " .$address->get('lastName');
|
||||||
$newProperties->{shippingAddress1} = $address->get('address1');
|
$newProperties->{shippingAddress1} = $address->get('address1');
|
||||||
$newProperties->{shippingAddress2} = $address->get('address2');
|
$newProperties->{shippingAddress2} = $address->get('address2');
|
||||||
$newProperties->{shippingAddress3} = $address->get('address3');
|
$newProperties->{shippingAddress3} = $address->get('address3');
|
||||||
|
|
@ -616,7 +616,7 @@ sub update {
|
||||||
if (exists $newProperties->{paymentAddress}) {
|
if (exists $newProperties->{paymentAddress}) {
|
||||||
my $address = $newProperties->{paymentAddress};
|
my $address = $newProperties->{paymentAddress};
|
||||||
$newProperties->{paymentAddressId} = $address->getId;
|
$newProperties->{paymentAddressId} = $address->getId;
|
||||||
$newProperties->{paymentAddressName} = $address->get('name');
|
$newProperties->{paymentAddressName} = $address->get('firstName') ." ". $address->get('lastName');
|
||||||
$newProperties->{paymentAddress1} = $address->get('address1');
|
$newProperties->{paymentAddress1} = $address->get('address1');
|
||||||
$newProperties->{paymentAddress2} = $address->get('address2');
|
$newProperties->{paymentAddress2} = $address->get('address2');
|
||||||
$newProperties->{paymentAddress3} = $address->get('address3');
|
$newProperties->{paymentAddress3} = $address->get('address3');
|
||||||
|
|
|
||||||
|
|
@ -650,6 +650,16 @@ our $I18N = {
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
context => q|a label in the address editor|
|
context => q|a label in the address editor|
|
||||||
},
|
},
|
||||||
|
'firstName' => {
|
||||||
|
message => q|First Name|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|a label in the address editor|
|
||||||
|
},
|
||||||
|
'lastName' => {
|
||||||
|
message => q|Last Name|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|a label in the address editor|
|
||||||
|
},
|
||||||
|
|
||||||
'address' => {
|
'address' => {
|
||||||
message => q|Address|,
|
message => q|Address|,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue