I am currently getting an error on login page:
Warning: Division by zero in /includes/modules/order_total/ot_group_pricing.php on line 79
Line 79:
PHP Code:
$ratio = $od_amount['total']/$order_total;
Printable View
I am currently getting an error on login page:
Warning: Division by zero in /includes/modules/order_total/ot_group_pricing.php on line 79
Line 79:
PHP Code:
$ratio = $od_amount['total']/$order_total;
I temporarily removed Group Discount from Module - Order Total to disable this error from the login page. We currently do not have any group discount in place. Can someone please clarify if this is needed by another function? I just want to make sure I am not making things worse. Thanks!
What version of Zen Cart?
Okay, I've seen this, but never on the login page.
Will research it as a minor bug.
Disabling group discounts for now should be fine, since, as you say, you don't use them.
Trouble is, you won't see it in PHP5. I got bit by a similar thing in Gift Wrap because I don't test in PHP4 anymore. Fix is straightforward: change
$ratio = $od_amount['total']/$order_total;
to
$ratio = 1;
if ($order_total != 0) {
$ratio = $od_amount['total']/$order_total;
}
sw_guy is correct.
I suggest this approach, which saves some CPU cycles and database queries:
/includes/modules/order_total/ot_group_pricing.php
around line 67 you'll see this section of code.
Add the line highlighted:Code:function calculate_deductions($order_total) {
global $db, $order;
$od_amount = array();
if ($order_total == 0) return $od_amount;
$orderTotal = $this->get_order_total();
DrByte, I think I follow now, instead of using SWGuy's code fix you're instructing me to apply your approach because it's an optimized approach using SWGuy's code logic.
I applied your changes (instead of SWGuy's) and that solved the problem.
Thanks to both of you for helping with this.