When the Sku for an item no longer exists, do not show links to it. Check for bad skus in Transaction/www_viewItem. Provide variables to not show links when the skus do not exist. Handle existing links better by not returning the user to the home page, but to the transaction. Fixes bug #12107.

This commit is contained in:
Colin Kuskie 2011-04-18 11:34:13 -07:00
parent e901b95520
commit cf36a1510f
7 changed files with 50 additions and 10 deletions

View file

@ -13,6 +13,7 @@
- fixed #12103: PayPalStd driver fails occasionally
- rfe #12105: Make shortcuts related for export purposes
- rfe #12108: Mail to Group preference field
- fixed #12107: Viewing an individual transaction item fails
7.10.13
- added #12079: Carousel Auto Play

View file

@ -1,6 +1,11 @@
This is a running list of template changes made during upgrades. If you have copied the default
templates, you will need to apply these changes manually to your copies.
7.10.14
* My Purchases Detail (Default) - shopping-cart-collateral-items/my-purchases-detail-default
* Email Receipt (Default) - shopping-cart-collateral-items/email-receipt-default
Added code to prevent links to items with bad skus to both templates.
7.10.13
* Cart (Default) - default-shopping-cart-template
In 7.10.7, hardcoded JavaScript was removed from the Cart code and migrated to the Cart template. The list of Javascript and files which are needed is below. Please add it to the Attachments or Extra Head Tags for any customized Cart templates.

View file

@ -740,6 +740,9 @@ our $HELP = {
{
name => 'viewItemUrl',
},
{
name => 'hasSku',
},
{
name => 'price',
description => 'price help',

View file

@ -463,11 +463,16 @@ sub getTransactionVars {
# Post purchase actions
my $actionsLoop = [];
my $actions = $item->getSku->getPostPurchaseActions( $item );
for my $label ( keys %{$actions} ) {
push @{$actionsLoop}, {
label => $label,
url => $actions->{$label},
my $sku = eval { $item->getSku };
my $has_sku = 0;
if (! WebGUI::Error->caught) {
my $actions = $sku->getPostPurchaseActions( $item );
$has_sku = 1;
for my $label ( keys %{$actions} ) {
push @{$actionsLoop}, {
label => $label,
url => $actions->{$label},
}
}
}
@ -485,7 +490,8 @@ sub getTransactionVars {
%{$item->get},
%taxVars,
viewItemUrl => $url->page('shop=transaction;method=viewItem;transactionId='.$self->getId.';itemId='.$item->getId, 1),
price => sprintf("%.2f", $item->get('price')),
hasSku => $hasSku,
price => sprintf( "%.2f", $item->get('price') ),
pricePlusTax => sprintf( "%.2f", $price + $taxAmount ),
extendedPrice => sprintf( "%.2f", $quantity * $price ),
extendedPricePlusTax => sprintf( "%.2f", $quantity * ( $price + $taxAmount ) ),
@ -1187,6 +1193,8 @@ sub www_view {
<tbody>
};
foreach my $item (@{$transaction->getItems}) {
eval { $item->getSku; };
my $sku_exists = !WebGUI::Error->caught;
$output .= WebGUI::Form::formHeader($session)
.WebGUI::Form::hidden($session, {name=>"shop",value=>"transaction"})
.WebGUI::Form::hidden($session, {name=>"method",value=>"updateItem"})
@ -1194,9 +1202,15 @@ sub www_view {
.WebGUI::Form::hidden($session, {name=>"itemId",value=>$item->getId})
.q{
<tr>
<td>}.$item->get('lastUpdated').q{</td>
<td><a href="}.$url->page('shop=transaction;method=viewItem;transactionId='.$transaction->getId.';itemId='.$item->getId).q{">}.$item->get('configuredTitle').q{</a></td>
<td>}.$transaction->formatCurrency($item->get('price')).q{</td>
<td>}.$item->get('lastUpdated').qq{</td>\n}.
(
$sku_exists
? q{<td><a href="}.$url->page('shop=transaction;method=viewItem;transactionId='.$transaction->getId
. ';itemId='.$item->getId).q{">}.$item->get('configuredTitle').qq{</a></td>\n}
: q{<td>}.$item->get('configuredTitle').q{<br />}.$i18n->get('item sku deleted').qq{</td>\n}
)
. q{<td>}.$transaction->formatCurrency($item->get('price')).q{</td>
<td>}.$item->get('quantity').q{</td>
};
if ($item->get('shippingAddressId') eq $transaction->get('shippingAddressId')) {
@ -1273,7 +1287,12 @@ sub www_viewItem {
$session->errorHandler->error("Can't get item ".$session->form->get("itemId"));
return $class->www_view($session);
}
return $item->getSku->www_view;
my $sku = eval { $item->getSku };
if (WebGUI::Error->caught()) {
$session->errorHandler->error("Can't get sku for ".$session->form->get("itemId"));
return $class->www_view($session);
}
return $sku->www_view;
}
#-------------------------------------------------------------------

View file

@ -1324,6 +1324,12 @@ our $I18N = {
context => q|Template variable for email receipt template|,
},
'hasSku' => {
message => q|A boolean which is true if the Asset that this item refers to is still in WebGUI. If this variable is false, then <b>viewItemUrl</b> should not be used.|,
lastUpdated => 1213135218,
context => q|Template variable for email receipt template|,
},
'price help' => {
message => q|The price of this item, formatted to two decimal places.|,
lastUpdated => 1213135218,
@ -2013,6 +2019,12 @@ our $I18N = {
context => q|Template variable help|
},
'item sku deleted' => {
message => q|The Asset for this item cannot be instanced.|,
lastUpdated => 0,
context => q|Template variable help|
},
};
1;