Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default [Done v1.3.9] Division by Zero in ot_group_pricing - v1.3.8

    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

  2. #2
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Division by Zero

    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!

  3. #3
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Division by Zero

    What version of Zen Cart?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Division by Zero

    Quote Originally Posted by DrByte View Post
    What version of Zen Cart?
    1.3.8a and this error currently only appears if I go directly to the login page. I go to the login page by adding and item to cart I don't get the error (I guess that makes sense because there is an item in cart).

  5. #5
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Division by Zero

    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.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,281
    Plugin Contributions
    125

    Default Re: Division by Zero in ot_group_pricing

    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;
    }
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  7. #7
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Division by Zero in ot_group_pricing

    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();
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Division by Zero in ot_group_pricing

    Quote Originally Posted by DrByte View Post
    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, Are you saying to apply this to the above section in addition to my original problem which is on line 79? Thanks!

  9. #9
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Division by Zero in ot_group_pricing

    Quote Originally Posted by swguy View Post
    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;
    }
    Thank you so much your fix solved the problem. Just an FYI you definitely will see it in PHP5 as our store is based on PHP 5.2.8 and MYSQL 5.0.45. PHP5 is not immuned to this problem.

    Thanks!

  10. #10
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Division by Zero in ot_group_pricing

    Quote Originally Posted by DrByte View Post
    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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Coupon division by zero?
    By Orchard_Direct in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 31 Jul 2009, 05:16 PM
  2. Division by Zero error
    By sinecurea in forum General Questions
    Replies: 4
    Last Post: 11 Sep 2007, 05:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR