From d8526028abf9ab9827cee966d37e949017aaa32e Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 3 Nov 2009 09:24:48 -0800 Subject: [PATCH] Fix small number handling in the Shop. Fixes bug #11195 Format the number to be checked against 0.00 in Shop/Pay.pm, since sometimes perl will leave small remainders when subtracting numbers. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Shop/Pay.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 322225c41..3cb89d568 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -37,6 +37,7 @@ - fixed #11190: event tmpl_var in help but not available - fixed #11194: Event Asset Recurrence form is not i18n'ed - fixed #11192: newByLineage tries to instantiate asset even if no assetId found + - fixed #11195: Shop, sometimes free checkout does not work 7.8.2 - Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi) diff --git a/lib/WebGUI/Shop/Pay.pm b/lib/WebGUI/Shop/Pay.pm index 515a614ff..d404538f0 100644 --- a/lib/WebGUI/Shop/Pay.pm +++ b/lib/WebGUI/Shop/Pay.pm @@ -409,7 +409,7 @@ sub www_selectPaymentGateway { # Complete Transaction if it's a $0 transaction. my $total = $cart->calculateTotal; - if (($total + $cart->calculateShopCreditDeduction($total)) == 0) { + if (sprintf('%.2f', $total + $cart->calculateShopCreditDeduction($total)) eq '0.00') { my $transaction = WebGUI::Shop::Transaction->create($session, {cart => $cart}); $transaction->completePurchase('zero', 'success', 'success'); $cart->onCompletePurchase;