From 674b2990695fad1c2f95d555e9cecf4835d9d3b0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 29 Apr 2010 14:51:06 -0700 Subject: [PATCH] Handle $0 checkouts. Still requires that ANY payment plugin be selected. --- lib/WebGUI/Shop/Cart.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index 8d8244da5..eaffdce21 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -913,6 +913,14 @@ sub www_update { $self->update({shippingAddressId => $self->get('billingAddressId')}); } if ($self->readyForCheckout()) { + my $total = $self->calculateTotal; + if (sprintf('%.2f', $total + $self->calculateShopCreditDeduction($total)) eq '0.00') { + my $transaction = WebGUI::Shop::Transaction->create($session, {self => $self}); + $transaction->completePurchase('zero', 'success', 'success'); + $self->onCompletePurchase; + $transaction->sendNotifications(); + return $transaction->thankYou(); + } my $gateway = WebGUI::Shop::Pay->new($session)->getPaymentGateway($self->get('gatewayId')); return $gateway->www_getCredentials; }