fixed more c2 bugs
added a workflow activity that removes EMS items from the cart if they've been in there too long
This commit is contained in:
parent
7e4e7898c0
commit
02c24aa44a
7 changed files with 128 additions and 3 deletions
|
|
@ -156,6 +156,7 @@ sub upgradeEMS {
|
|||
price float not null default 0.00,
|
||||
primary key (assetId, revisionDate)
|
||||
)");
|
||||
$session->config->addToArray("workflowActivities/None","WebGUI::Workflow::Activity::ExpireEmsCartItems");
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ Update the cart and then redirect the user to the payment gateway screen.
|
|||
|
||||
=cut
|
||||
|
||||
sub www_continueShopping {
|
||||
sub www_checkout {
|
||||
my $self = shift;
|
||||
$self->updateFromForm;
|
||||
if ($error{id $self} ne "") {
|
||||
|
|
@ -643,7 +643,7 @@ sub www_view {
|
|||
formFooter => WebGUI::Form::formFooter($session),
|
||||
updateButton => WebGUI::Form::submit($session, {value=>$i18n->get("update cart button")}),
|
||||
checkoutButton => WebGUI::Form::submit($session, {value=>$i18n->get("checkout button"),
|
||||
extras=>q|onclick="this.form.shop.value='pay';this.form.method.value='selectPaymentGateway';this.form.submit;"|}),
|
||||
extras=>q|onclick="this.form.method.value='checkout';this.form.submit;"|}),
|
||||
continueShoppingButton => WebGUI::Form::submit($session, {value=>$i18n->get("continue shopping button"),
|
||||
extras=>q|onclick="this.form.method.value='continueShopping';this.form.submit;"|}),
|
||||
chooseShippingButton => WebGUI::Form::submit($session, {value=>$i18n->get("choose shipping button"),
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ Returns the WebGUI::Shop::Address object that is attached to this item for shipp
|
|||
sub getShippingAddress {
|
||||
my $self = shift;
|
||||
my $addressId = $self->get("shippingAddressId") || $self->cart->get("shippingAddressId");
|
||||
$self->cart->session->errorHandler->warn("address id: ". $addressId);
|
||||
return $self->cart->getAddressBook->getAddress($addressId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ sub processTransaction {
|
|||
if ($success) {
|
||||
$transaction->completePurchase($transactionCode, $statusCode, $statusMessage);
|
||||
$cart->onCompletePurchase;
|
||||
$self->sendNotifications($transaction);
|
||||
# $self->sendNotifications($transaction);
|
||||
}
|
||||
else {
|
||||
$transaction->denyPurchase($transactionCode, $statusCode, $statusMessage);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ sub handler {
|
|||
my $output = eval { WebGUI::Pluggable::run($handler, "handler", [ $session ] ) };
|
||||
if ( my $e = WebGUI::Error->caught ) {
|
||||
$session->errorHandler->error($e->package.":".$e->line." - ".$e->error);
|
||||
$session->errorHandler->debug($e->package.":".$e->line." - ".$e->trace);
|
||||
}
|
||||
else {
|
||||
if ($output eq "chunked") {
|
||||
|
|
|
|||
104
lib/WebGUI/Workflow/Activity/ExpireEmsCartItems.pm
Normal file
104
lib/WebGUI/Workflow/Activity/ExpireEmsCartItems.pm
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
package WebGUI::Workflow::Activity::ExpireEmsCartItems;
|
||||
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::Shop::Cart;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Workflow::Activity::ExpireEmsCartItems
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Removes EMS items from shopping carts that have been held up by the user too long.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
See WebGUI::Workflow::Activity for details on how to use any activity.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
See WebGUI::Workflow::Activity::defintion() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
|
||||
push(@{$definition}, {
|
||||
name=>$i18n->get("expire ems cart items"),
|
||||
properties=> {
|
||||
expireAfter => {
|
||||
fieldType=>"interval",
|
||||
label=>$i18n->get("item expiration time"),
|
||||
defaultValue=>60*60,
|
||||
hoverHelp=>$i18n->get('item expiration time help')
|
||||
},
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 execute ( [ object ] )
|
||||
|
||||
See WebGUI::Workflow::Activity::execute() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $object = shift;
|
||||
my $instance = shift;
|
||||
my $start = time();
|
||||
my $log = $self->session->errorHandler;
|
||||
$log->info('Searching for EMS items that have been in the cart too long.');
|
||||
my $items = $self->session->db->read("select itemId, cartId, assetId from cartItem where
|
||||
assetId in (select assetId from asset where className like 'WebGUI::Asset::Sku::EMS%')
|
||||
and DATE_ADD(dateAdded, interval ".($self->get("expireAfter") + 0)." second) < now()");
|
||||
while (my ($itemId, $cartId, $assetId) = $items->array) {
|
||||
$log->info('Removing item '.$itemId.' (asset '.$assetId.') from cart '.$cartId);
|
||||
WebGUI::Shop::Cart->new($self->session, $cartId)->getItem($itemId)->remove;
|
||||
if (time() - $start > 55) {
|
||||
$items->finish;
|
||||
$log->('Ran out of time. Will have to expire the rest later.');
|
||||
return $self->WAITING;
|
||||
}
|
||||
}
|
||||
$log->info('No more EMS items to expire.');
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -2,6 +2,24 @@ package WebGUI::i18n::English::Asset_EventManagementSystem;
|
|||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'expire ems cart items' => {
|
||||
message => q|Expire EMS Cart Items|,
|
||||
lastUpdated => 0,
|
||||
context => q|workflow activity title|,
|
||||
},
|
||||
|
||||
'item expiration time' => {
|
||||
message => q|Item Expiration Time|,
|
||||
lastUpdated => 0,
|
||||
context => q|a workflow activity field label|,
|
||||
},
|
||||
|
||||
'item expiration time help' => {
|
||||
message => q|How long should EMS items be allowed to sit in a cart before they are expired to be freed up for someone else to purchase?|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for a workflow activity field label|,
|
||||
},
|
||||
|
||||
'percentage discount' => {
|
||||
message => q|Percentage Discount|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue