fixed several checkout bugs
This commit is contained in:
parent
ca61c81967
commit
7e4e7898c0
5 changed files with 60 additions and 29 deletions
|
|
@ -132,7 +132,7 @@ Does bookkeeping on EMSRegistrationRibbon table.
|
|||
|
||||
sub onCompletePurchase {
|
||||
my ($self, $item) = @_;
|
||||
$self->session->db->write("insert into EMSRegistrationRibbon (ribbonAssetId, badgeId) values (?,?)",
|
||||
$self->session->db->write("insert into EMSRegistrantRibbon (ribbonAssetId, badgeId) values (?,?)",
|
||||
[$self->getId, $self->getOptions->{badgeId}]);
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,10 @@ sub onCompletePurchase {
|
|||
my $currentQuantity = $db->quickScalar("select quantity from EMSRegistrantToken where tokenAssetId=? and badgeId=?",\@params);
|
||||
unshift @params, $item->get("quantity");
|
||||
if (defined $currentQuantity) {
|
||||
$db->write("update EMSRegistrationToken set quantity=quantity+? where tokenAssetId=? and badgeId=?",\@params);
|
||||
$db->write("update EMSRegistrantToken set quantity=quantity+? where tokenAssetId=? and badgeId=?",\@params);
|
||||
}
|
||||
else {
|
||||
$db->write("insert into EMSRegistrationToken (quantity, tokenAssetId, badgeId) values (?,?,?)",\@params);
|
||||
$db->write("insert into EMSRegistrantToken (quantity, tokenAssetId, badgeId) values (?,?,?)",\@params);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -399,11 +399,11 @@ sub readyForCheckout {
|
|||
my $self = shift;
|
||||
|
||||
# Check if the shipping address is set and correct
|
||||
my $address = $self->getShippingAddress;
|
||||
my $address = eval{$self->getShippingAddress};
|
||||
return 0 if WebGUI::Error->caught;
|
||||
|
||||
# Check if the ship driver is chosen and existant
|
||||
my $ship = $self->getShipper;
|
||||
my $ship = eval {$self->getShipper};
|
||||
return 0 if WebGUI::Error->caught;
|
||||
|
||||
# Check if the cart has items
|
||||
|
|
@ -467,6 +467,53 @@ sub update {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 updateFromForm ( )
|
||||
|
||||
Updates the cart totals.
|
||||
|
||||
=cut
|
||||
|
||||
sub updateFromForm {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
foreach my $item (@{$self->getItems}) {
|
||||
if ($form->get("quantity-".$item->getId) ne "") {
|
||||
eval { $item->setQuantity($form->get("quantity-".$item->getId)) };
|
||||
if (WebGUI::Error->caught("WebGUI::Error::Shop::MaxOfItemInCartReached")) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||
$error{id $self} = sprint($i18n->get("too many of this item"), $item->get("configuredTitle"));
|
||||
}
|
||||
elsif (my $e = WebGUI::Error->caught) {
|
||||
$error{id $self} = "An unknown error has occured: ".$e->message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $cartProperties;
|
||||
$cartProperties->{ shipperId } = $form->process( 'shipperId' ) if $form->process( 'shipperId' );
|
||||
$self->update( $cartProperties );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_checkout ( )
|
||||
|
||||
Update the cart and then redirect the user to the payment gateway screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_continueShopping {
|
||||
my $self = shift;
|
||||
$self->updateFromForm;
|
||||
if ($error{id $self} ne "") {
|
||||
return $self->www_view;
|
||||
}
|
||||
$self->session->http->setRedirect($self->session->url->page('shop=pay;method=selectPaymentGateway'));
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_continueShopping ( )
|
||||
|
||||
Update the cart and the return the user back to the asset.
|
||||
|
|
@ -475,9 +522,9 @@ Update the cart and the return the user back to the asset.
|
|||
|
||||
sub www_continueShopping {
|
||||
my $self = shift;
|
||||
my $cartView = $self->www_update;
|
||||
$self->updateFromForm;
|
||||
if ($error{id $self} ne "") {
|
||||
return $cartView;
|
||||
return $self->www_view;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -529,24 +576,7 @@ Updates the cart totals and then displays the cart again.
|
|||
|
||||
sub www_update {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
foreach my $item (@{$self->getItems}) {
|
||||
if ($form->get("quantity-".$item->getId) ne "") {
|
||||
eval { $item->setQuantity($form->get("quantity-".$item->getId)) };
|
||||
if (WebGUI::Error->caught("WebGUI::Error::Shop::MaxOfItemInCartReached")) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||
$error{id $self} = sprint($i18n->get("too many of this item"), $item->get("configuredTitle"));
|
||||
}
|
||||
elsif (my $e = WebGUI::Error->caught) {
|
||||
$error{id $self} = "An unknown error has occured: ".$e->message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $cartProperties;
|
||||
$cartProperties->{ shipperId } = $form->process( 'shipperId' ) if $form->process( 'shipperId' );
|
||||
$self->update( $cartProperties );
|
||||
|
||||
$self->updateFromForm;
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -500,12 +500,12 @@ sub processTransaction {
|
|||
});
|
||||
my ($success, $transactionCode, $statusCode, $statusMessage) = $self->processPayment;
|
||||
if ($success) {
|
||||
$transaction->completePurchase($cart, $transactionCode, $statusCode, $statusMessage);
|
||||
$transaction->completePurchase($transactionCode, $statusCode, $statusMessage);
|
||||
$cart->onCompletePurchase;
|
||||
$self->sendNotifications($transaction);
|
||||
}
|
||||
else {
|
||||
$transaction->denyTransaction($transactionCode, $statusCode, $statusMessage);
|
||||
$transaction->denyPurchase($transactionCode, $statusCode, $statusMessage);
|
||||
}
|
||||
return $transaction;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::URL::Content;
|
|||
use strict;
|
||||
use Apache2::Const -compile => qw(OK DECLINED);
|
||||
use WebGUI::Affiliate;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Session;
|
||||
|
||||
|
|
@ -53,8 +54,8 @@ sub handler {
|
|||
my $session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server);
|
||||
foreach my $handler (@{$config->get("contentHandlers")}) {
|
||||
my $output = eval { WebGUI::Pluggable::run($handler, "handler", [ $session ] ) };
|
||||
if ( $@ ) {
|
||||
$session->errorHandler->error($@);
|
||||
if ( my $e = WebGUI::Error->caught ) {
|
||||
$session->errorHandler->error($e->package.":".$e->line." - ".$e->error);
|
||||
}
|
||||
else {
|
||||
if ($output eq "chunked") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue