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 precision 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/uc_order_get_total_roundi...

Joined: 08/07/2007
Juice: 15046

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

Joined: 08/14/2007
Juice: 3867
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!

Joined: 08/07/2007
Juice: 15046
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