diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 11a0e4e6b..9acb3cd48 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,6 +1,7 @@ 7.10.14 - fixed #12094: Cannot enter in Macros in URLs inside TinyMCE. - rfe #12093: Remotely stored photos for Story assets + - fixed #12088: Organization left out of transaction 7.10.13 - added #12079: Carousel Auto Play diff --git a/docs/upgrades/upgrade_7.10.13-7.10.14.pl b/docs/upgrades/upgrade_7.10.13-7.10.14.pl index 4ea09cb05..3baf32403 100644 --- a/docs/upgrades/upgrade_7.10.13-7.10.14.pl +++ b/docs/upgrades/upgrade_7.10.13-7.10.14.pl @@ -31,6 +31,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +addOrganizationsToTransaction($session); finish($session); # this line required @@ -45,6 +46,18 @@ finish($session); # this line required #} +#---------------------------------------------------------------------------- +# Describe what our function does +sub addOrganizationsToTransaction { + my $session = shift; + print "\tAdd organization fields to the addresses stored in the Transaction and TransactionItem... " unless $quiet; + # and here's our code + $session->db->write('ALTER TABLE transaction ADD COLUMN shippingOrganization CHAR(35)'); + $session->db->write('ALTER TABLE transaction ADD COLUMN paymentOrganization CHAR(35)'); + $session->db->write('ALTER TABLE transactionItem ADD COLUMN shippingOrganization CHAR(35)'); + print "DONE!\n" unless $quiet; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/Shop/Transaction.pm b/lib/WebGUI/Shop/Transaction.pm index b37f253b3..4e089ae3d 100644 --- a/lib/WebGUI/Shop/Transaction.pm +++ b/lib/WebGUI/Shop/Transaction.pm @@ -261,7 +261,9 @@ A hash reference with the address properties. sub formatAddress { my ($self, $address) = @_; - my $formatted = $address->{name} . "
" . $address->{address1} . "
"; + my $formatted = $address->{name} . "
"; + $formatted .= $address->{organization} . "
" if ($address->{organization} ne ""); + $formatted .= $address->{address1} . "
"; $formatted .= $address->{address2} . "
" if ($address->{address2} ne ""); $formatted .= $address->{address3} . "
" if ($address->{address3} ne ""); $formatted .= $address->{city} . ", "; @@ -415,26 +417,28 @@ sub getTransactionVars { taxes => sprintf( "%.2f", $self->get('taxes') ), shippingPrice => sprintf( "%.2f", $self->get('shippingPrice') ), shippingAddress => $self->formatAddress( { - name => $self->get('shippingAddressName'), - address1 => $self->get('shippingAddress1'), - address2 => $self->get('shippingAddress2'), - address3 => $self->get('shippingAddress3'), - city => $self->get('shippingCity'), - state => $self->get('shippingState'), - code => $self->get('shippingCode'), - country => $self->get('shippingCountry'), - phoneNumber => $self->get('shippingPhoneNumber'), + name => $self->get('shippingAddressName'), + organization => $self->get('shippingOrganization'), + address1 => $self->get('shippingAddress1'), + address2 => $self->get('shippingAddress2'), + address3 => $self->get('shippingAddress3'), + city => $self->get('shippingCity'), + state => $self->get('shippingState'), + code => $self->get('shippingCode'), + country => $self->get('shippingCountry'), + phoneNumber => $self->get('shippingPhoneNumber'), } ), paymentAddress => $self->formatAddress({ - name => $self->get('paymentAddressName'), - address1 => $self->get('paymentAddress1'), - address2 => $self->get('paymentAddress2'), - address3 => $self->get('paymentAddress3'), - city => $self->get('paymentCity'), - state => $self->get('paymentState'), - code => $self->get('paymentCode'), - country => $self->get('paymentCountry'), - phoneNumber => $self->get('paymentPhoneNumber'), + name => $self->get('paymentAddressName'), + organization => $self->get('paymentOrganization'), + address1 => $self->get('paymentAddress1'), + address2 => $self->get('paymentAddress2'), + address3 => $self->get('paymentAddress3'), + city => $self->get('paymentCity'), + state => $self->get('paymentState'), + code => $self->get('paymentCode'), + country => $self->get('paymentCountry'), + phoneNumber => $self->get('paymentPhoneNumber'), } ), }; @@ -444,15 +448,16 @@ sub getTransactionVars { my $address = ''; if ($self->get('shippingAddressId') ne $item->get('shippingAddressId')) { $address = $self->formatAddress({ - name => $item->get('shippingAddressName'), - address1 => $item->get('shippingAddress1'), - address2 => $item->get('shippingAddress2'), - address3 => $item->get('shippingAddress3'), - city => $item->get('shippingCity'), - state => $item->get('shippingState'), - code => $item->get('shippingCode'), - country => $item->get('shippingCountry'), - phoneNumber => $item->get('shippingPhoneNumber'), + name => $item->get('shippingAddressName'), + organization => $self->get('shippingOrganization'), + address1 => $item->get('shippingAddress1'), + address2 => $item->get('shippingAddress2'), + address3 => $item->get('shippingAddress3'), + city => $item->get('shippingCity'), + state => $item->get('shippingState'), + code => $item->get('shippingCode'), + country => $item->get('shippingCountry'), + phoneNumber => $item->get('shippingPhoneNumber'), }); } @@ -747,28 +752,30 @@ sub update { $newProperties->{taxes} = $cart->calculateTaxes; my $billingAddress = $cart->getBillingAddress; - $newProperties->{paymentAddressId} = $billingAddress->getId; - $newProperties->{paymentAddressName} = $billingAddress->get('firstName') . " " . $billingAddress->get('lastName'); - $newProperties->{paymentAddress1} = $billingAddress->get('address1'); - $newProperties->{paymentAddress2} = $billingAddress->get('address2'); - $newProperties->{paymentAddress3} = $billingAddress->get('address3'); - $newProperties->{paymentCity} = $billingAddress->get('city'); - $newProperties->{paymentState} = $billingAddress->get('state'); - $newProperties->{paymentCountry} = $billingAddress->get('country'); - $newProperties->{paymentCode} = $billingAddress->get('code'); - $newProperties->{paymentPhoneNumber} = $billingAddress->get('phoneNumber'); + $newProperties->{paymentAddressId} = $billingAddress->getId; + $newProperties->{paymentAddressName} = $billingAddress->get('firstName') . " " . $billingAddress->get('lastName'); + $newProperties->{paymentOrganization} = $billingAddress->get('organization'); + $newProperties->{paymentAddress1} = $billingAddress->get('address1'); + $newProperties->{paymentAddress2} = $billingAddress->get('address2'); + $newProperties->{paymentAddress3} = $billingAddress->get('address3'); + $newProperties->{paymentCity} = $billingAddress->get('city'); + $newProperties->{paymentState} = $billingAddress->get('state'); + $newProperties->{paymentCountry} = $billingAddress->get('country'); + $newProperties->{paymentCode} = $billingAddress->get('code'); + $newProperties->{paymentPhoneNumber} = $billingAddress->get('phoneNumber'); my $shippingAddress = $cart->getShippingAddress; - $newProperties->{shippingAddressId} = $shippingAddress->getId; - $newProperties->{shippingAddressName} = $shippingAddress->get('firstName') . " " . $shippingAddress->get('lastName'); - $newProperties->{shippingAddress1} = $shippingAddress->get('address1'); - $newProperties->{shippingAddress2} = $shippingAddress->get('address2'); - $newProperties->{shippingAddress3} = $shippingAddress->get('address3'); - $newProperties->{shippingCity} = $shippingAddress->get('city'); - $newProperties->{shippingState} = $shippingAddress->get('state'); - $newProperties->{shippingCountry} = $shippingAddress->get('country'); - $newProperties->{shippingCode} = $shippingAddress->get('code'); - $newProperties->{shippingPhoneNumber} = $shippingAddress->get('phoneNumber'); + $newProperties->{shippingAddressId} = $shippingAddress->getId; + $newProperties->{shippingAddressName} = $shippingAddress->get('firstName') . " " . $shippingAddress->get('lastName'); + $newProperties->{shippingOrganization} = $shippingAddress->get('organization'); + $newProperties->{shippingAddress1} = $shippingAddress->get('address1'); + $newProperties->{shippingAddress2} = $shippingAddress->get('address2'); + $newProperties->{shippingAddress3} = $shippingAddress->get('address3'); + $newProperties->{shippingCity} = $shippingAddress->get('city'); + $newProperties->{shippingState} = $shippingAddress->get('state'); + $newProperties->{shippingCountry} = $shippingAddress->get('country'); + $newProperties->{shippingCode} = $shippingAddress->get('code'); + $newProperties->{shippingPhoneNumber} = $shippingAddress->get('phoneNumber'); if ($cart->requiresShipping) { my $shipper = $cart->getShipper; @@ -803,7 +810,8 @@ sub update { shippingCountry shippingCode shippingPhoneNumber shippingDriverId shippingDriverLabel notes shippingPrice paymentAddressId paymentAddressName originatingTransactionId isRecurring paymentAddress1 paymentAddress2 paymentAddress3 paymentCity paymentState paymentCountry paymentCode - paymentPhoneNumber paymentDriverId paymentDriverLabel taxes shopCreditDeduction)); + paymentPhoneNumber paymentDriverId paymentDriverLabel taxes shopCreditDeduction + shippingOrganization paymentOrganization)); foreach my $field (@fields) { $properties{$id}{$field} = (exists $newProperties->{$field}) ? $newProperties->{$field} : $properties{$id}{$field}; } @@ -1125,15 +1133,16 @@ sub www_view { }. $i18n->get("shipping address") .q{}. $transaction->formatAddress({ - name => $transaction->get('shippingAddressName'), - address1 => $transaction->get('shippingAddress1'), - address2 => $transaction->get('shippingAddress2'), - address3 => $transaction->get('shippingAddress3'), - city => $transaction->get('shippingCity'), - state => $transaction->get('shippingState'), - code => $transaction->get('shippingCode'), - country => $transaction->get('shippingCountry'), - phoneNumber => $transaction->get('shippingPhoneNumber'), + name => $transaction->get('shippingAddressName'), + organization => $transaction->get('shippingOrganization'), + address1 => $transaction->get('shippingAddress1'), + address2 => $transaction->get('shippingAddress2'), + address3 => $transaction->get('shippingAddress3'), + city => $transaction->get('shippingCity'), + state => $transaction->get('shippingState'), + code => $transaction->get('shippingCode'), + country => $transaction->get('shippingCountry'), + phoneNumber => $transaction->get('shippingPhoneNumber'), }) .q{ @@ -1144,15 +1153,16 @@ sub www_view { }. $i18n->get("payment address") .q{}. $transaction->formatAddress({ - name => $transaction->get('paymentAddressName'), - address1 => $transaction->get('paymentAddress1'), - address2 => $transaction->get('paymentAddress2'), - address3 => $transaction->get('paymentAddress3'), - city => $transaction->get('paymentCity'), - state => $transaction->get('paymentState'), - code => $transaction->get('paymentCode'), - country => $transaction->get('paymentCountry'), - phoneNumber => $transaction->get('paymentPhoneNumber'), + name => $transaction->get('paymentAddressName'), + organization => $transaction->get('paymentOrganization'), + address1 => $transaction->get('paymentAddress1'), + address2 => $transaction->get('paymentAddress2'), + address3 => $transaction->get('paymentAddress3'), + city => $transaction->get('paymentCity'), + state => $transaction->get('paymentState'), + code => $transaction->get('paymentCode'), + country => $transaction->get('paymentCountry'), + phoneNumber => $transaction->get('paymentPhoneNumber'), }) .q{ @@ -1195,15 +1205,16 @@ sub www_view { else { $output .= q{ }. $transaction->formatAddress({ - name => $item->get('shippingAddressName'), - address1 => $item->get('shippingAddress1'), - address2 => $item->get('shippingAddress2'), - address3 => $item->get('shippingAddress3'), - city => $item->get('shippingCity'), - state => $item->get('shippingState'), - code => $item->get('shippingCode'), - country => $item->get('shippingCountry'), - phoneNumber => $item->get('shippingPhoneNumber'), + name => $item->get('shippingAddressName'), + organization => $item->get('shippingOrganization'), + address1 => $item->get('shippingAddress1'), + address2 => $item->get('shippingAddress2'), + address3 => $item->get('shippingAddress3'), + city => $item->get('shippingCity'), + state => $item->get('shippingState'), + code => $item->get('shippingCode'), + country => $item->get('shippingCountry'), + phoneNumber => $item->get('shippingPhoneNumber'), }) .q{ }; } diff --git a/lib/WebGUI/Shop/TransactionItem.pm b/lib/WebGUI/Shop/TransactionItem.pm index ab238a767..14757e145 100644 --- a/lib/WebGUI/Shop/TransactionItem.pm +++ b/lib/WebGUI/Shop/TransactionItem.pm @@ -254,8 +254,8 @@ A hash reference that contains one of the following: A reference to a WebGUI::Shop::CartItem. Alternatively you can manually pass in any of the following fields that would be created automatically by this object: assetId configuredTitle options shippingAddressId -shippingName shippingAddress1 shippingAddress2 shippingAddress3 shippingCity shippingState shippingCountry -shippingCode shippingPhoneNumber quantity price vendorId +shippingName shippingAddress1 shippingOrganization shippingAddress2 shippingAddress3 shippingCity shippingState +shippingCountry shippingCode shippingPhoneNumber quantity price vendorId =head4 shippingTrackingNumber @@ -288,6 +288,7 @@ sub update { my $address = $item->getShippingAddress; $newProperties->{ shippingAddressId } = $address->getId; $newProperties->{ shippingAddressName } = join ' ', $address->get('firstName'), $address->get('lastName'); + $newProperties->{ shippingOrganization } = $address->get('organization'); $newProperties->{ shippingAddress1 } = $address->get('address1'); $newProperties->{ shippingAddress2 } = $address->get('address2'); $newProperties->{ shippingAddress3 } = $address->get('address3'); @@ -309,7 +310,7 @@ sub update { my @fields = (qw(assetId configuredTitle options shippingAddressId shippingTrackingNumber orderStatus shippingName shippingAddress1 shippingAddress2 shippingAddress3 shippingCity shippingState shippingCountry shippingCode shippingPhoneNumber quantity price vendorId - vendorPayoutStatus vendorPayoutAmount taxRate taxConfiguration)); + vendorPayoutStatus vendorPayoutAmount taxRate taxConfiguration shippingOrganization)); foreach my $field (@fields) { $properties{$id}{$field} = (exists $newProperties->{$field}) ? $newProperties->{$field} : $properties{$id}{$field}; } diff --git a/t/Shop/Transaction.t b/t/Shop/Transaction.t index 3981a46e6..df672392c 100644 --- a/t/Shop/Transaction.t +++ b/t/Shop/Transaction.t @@ -18,6 +18,7 @@ use strict; use lib "$FindBin::Bin/../lib"; use Test::More; use Test::Deep; +use Test::LongString; use WebGUI::Test; # Must use this before any other WebGUI modules use WebGUI::Session; use WebGUI::Shop::Transaction; @@ -32,39 +33,41 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 77; # Increment this number for each test you create +plan tests => 83; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here my $transaction = WebGUI::Shop::Transaction->create($session,{ - amount => 40, - shippingAddressId => 'xxx1', - shippingAddressName => 'abc', - shippingAddress1 => 'def', - shippingAddress2 => 'hij', - shippingAddress3 => 'lmn', - shippingCity => 'opq', - shippingState => 'wxy', - shippingCountry => 'z', - shippingCode => '53333', - shippingPhoneNumber => '123456', - shippingDriverId => 'xxx2', - shippingDriverLabel => 'foo', - shippingPrice => 5, - paymentAddressId => 'xxx3', - paymentAddressName => 'abc1', - paymentAddress1 => 'def1', - paymentAddress2 => 'hij1', - paymentAddress3 => 'lmn1', - paymentCity => 'opq1', - paymentState => 'wxy1', - paymentCountry => 'z1', - paymentCode => '66666', - paymentPhoneNumber => '908765', - paymentDriverId => 'xxx4', - paymentDriverLabel => 'kkk', - taxes => 7, + amount => 40, + shippingAddressId => 'xxx1', + shippingAddressName => 'abc', + shippingOrganization => 'Ship To Us', + shippingAddress1 => 'def', + shippingAddress2 => 'hij', + shippingAddress3 => 'lmn', + shippingCity => 'opq', + shippingState => 'wxy', + shippingCountry => 'z', + shippingCode => '53333', + shippingPhoneNumber => '123456', + shippingDriverId => 'xxx2', + shippingDriverLabel => 'foo', + shippingPrice => 5, + paymentAddressId => 'xxx3', + paymentAddressName => 'abc1', + paymentOrganization => 'Pay To Us', + paymentAddress1 => 'def1', + paymentAddress2 => 'hij1', + paymentAddress3 => 'lmn1', + paymentCity => 'opq1', + paymentState => 'wxy1', + paymentCountry => 'z1', + paymentCode => '66666', + paymentPhoneNumber => '908765', + paymentDriverId => 'xxx4', + paymentDriverLabel => 'kkk', + taxes => 7, }); addToCleanup($transaction); @@ -76,6 +79,7 @@ isa_ok($transaction->session, "WebGUI::Session"); # basic transaction properties is($transaction->get("amount"), 40, "set and get amount"); is($transaction->get("shippingAddressId"), 'xxx1', "set and get shipping address id"); +is($transaction->get("shippingOrganization"), 'Ship To Us', "set and get shipping organization"); is($transaction->get("shippingAddressName"), 'abc', "set and get shipping address name"); is($transaction->get("shippingAddress1"), 'def', "set and get shipping address 1"); is($transaction->get("shippingAddress2"), 'hij', "set and get shipping address 2"); @@ -90,6 +94,7 @@ is($transaction->get("shippingDriverLabel"), 'foo', "set and get shipping driver is($transaction->get("shippingPrice"), 5, "set and get shipping price"); is($transaction->get("paymentAddressId"), 'xxx3', "set and get payment address id"); is($transaction->get("paymentAddressName"), 'abc1', "set and get payment address name"); +is($transaction->get("paymentOrganization"), 'Pay To Us', "set and get payment organization"); is($transaction->get("paymentAddress1"), 'def1', "set and get payment address 1"); is($transaction->get("paymentAddress2"), 'hij1', "set and get payment address 2"); is($transaction->get("paymentAddress3"), 'lmn1', "set and get payment address 3"); @@ -128,6 +133,7 @@ my $item = $transaction->addItem({ assetId => 'a', configuredTitle => 'b', options => {color=>'blue'}, + shippingOrganization => 'organized', shippingAddressId => 'c', shippingName => 'd', shippingAddress1 => 'e', @@ -162,6 +168,7 @@ is($item->get("shippingPhoneNumber"), 'l', "set and get shipping phone number"); is($item->get("quantity"), 5, "set and get quantity"); is($item->get("price"), 33, "set and get price"); is($item->get('taxRate'), 19, 'set and get taxRate' ); +is($item->get('shippingOrganization'), 'organized', 'set and get shipping organization' ); $item->update({ shippingTrackingNumber => 'adfs', @@ -283,6 +290,50 @@ $session->setting->set('shopReceiptEmailTemplateId', $templateId); WebGUI::Test->unmockAssetId($templateId); } +####################################################################### +# +# formatAddress +# +####################################################################### + +my $formattedAddress = $transaction->formatAddress({ + name => 'Red', + address1 => 'Cell Block #5', + city => 'Shawshank', + state => 'MN', + code => 55555, + country => 'USA', + phoneNumber => '555.555.5555', +}); + +is_string $formattedAddress, 'Red
Cell Block #5
Shawshank, MN 55555
USA
555.555.5555', 'formatAddress: a regular address'; + +my $formattedAddress = $transaction->formatAddress({ + name => 'Red', + address1 => 'Cell Block #5', + address2 => 'Next to Andy', + city => 'Shawshank', + state => 'MN', + code => 55555, + country => 'USA', + phoneNumber => '555.555.5555', +}); + +is_string $formattedAddress, 'Red
Cell Block #5
Next to Andy
Shawshank, MN 55555
USA
555.555.5555', '... a regular address with address2'; + +my $formattedAddress = $transaction->formatAddress({ + name => 'Red', + organization => 'Shawshank Prison', + address1 => 'Cell Block #5', + city => 'Shawshank', + state => 'MN', + code => 55555, + country => 'USA', + phoneNumber => '555.555.5555', +}); + +is_string $formattedAddress, 'Red
Shawshank Prison
Cell Block #5
Shawshank, MN 55555
USA
555.555.5555', '... a regular address with address2'; + ####################################################################### # # delete