The revisions let you track differences between multiple versions of a post.

Checking order_total against zero (floating point precision)

Project:Gift Certificate Module
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Gift Certificate

Came across a floating point comparison problem.
In uc_payment_method_zero_total()

      if ($total != 0) {
        $result[] = array(
            'pass' => FALSE,
            'message' => t("Your final order total is $total, not $0.  Please go back and select a different method of payment.")
            );

Testing against ZERO is bad and might fail, this should be replaced by something like

if ($total > 0.001)

At least this fix worked for me.

More info here:
http://www.ubercart.org/forum/bug_reports/4620

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Checking order_total against zero (floating point precision)

I wonder if you should just disable the zero total payment method in here and use my free order payment method available here. Puzzled

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Checking order_total against zero (floating point precis
Assigned to:Ryan» torgosPizza

I think Zero Total payment method is part of the gift certificate module. If it's easy enough to change the module so that it interacts with your free order payment method, I'd like to know how it's done Smiling Honestly I haven't dug that much into it so that might be kind of a silly question to ask, so I will check out your link as well. Thanks, Ryan!

--
Help directly fund development: Donate via PayPal!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Checking order_total against zero (floating point pr
Assigned to:torgosPizza» Ryan

The free order one was what I put together as a result of some work for WBR. I don't think I knew there was a payment method in here, too. However, if the gift certificate module did it properly as a payment method, you should just be able to disable the one and enable the free order. Of course, if it's not broken, there's no reason to fix it. Smiling