Division by zero error with certain shipping options


  • Default avatar
    donald6    
     7 years ago
    0

    I created a manual shipping option in Hikashop set to $0 for people who want to order and pick up their products locally.  However, when that option is selected, I get the error:

    Warning: Division by zero in /home/fudgeby/public_html/administrator/components/com_awocoupon/helpers/estore/hikashop/couponhandler.php on line 722

    The error goes away when the other manual shipping option is selected, which I set to $6 as a flat rate.

    j! 3.7.3
    Hikashop 3.1.1
    AWO Coupon 2.5.7
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    In that same file, and same line, change

    <?php
                        
    'tax_rate' => ($this_total_shipping-$this_total_shipping_notax)/$this_total_shipping_notax,
    ?>


    to
    <?php
                        
    'tax_rate' => empty($this_total_shipping_notax) ? : ($this_total_shipping-$this_total_shipping_notax)/$this_total_shipping_notax,
    ?>


    That should fix the warning.
  • Default avatar
    donald6    
     7 years ago
    0

    I did change the code, but I am still getting the exact same warning.  I double checked that the correct file and line was changed to your suggestion.
  • Your avatar
    seyi    
     7 years ago
    0

    Very strange, that should fix it.  This is now updated in the latest, 2.5.8, can you upgrade to see if that fixes it?
  • Default avatar
    donald6    
     7 years ago
    0

    I did the upgrade to 2.5.8, but I still get the same exact error.
  • Your avatar
    seyi    
     7 years ago  last edited 7 years ago
    0

    Hello,

    Can you send a private message with instructions on how to test it?

    Ok, found a solution.

    In the same file, around line 718 is this:
    <?php
                    $shippings
    [] = (object) array(
                        'shipping_id'=>$shipping_id,
                        'total_notax'=>$this_total_shipping_notax,
                        'total'=>$this_total_shipping,
                        'tax_rate' => empty($this_total_shipping_notax) ? : ($this_total_shipping-$this_total_shipping_notax)/$this_total_shipping_notax,
                        'totaldiscount'=>0,
                        'totaldiscount_notax'=>0,
                        'totaldiscount_tax'=>0,
                        'coupons'=>array(),
                    );
    ?>


    Right before that add this:
    <?php
                    $this_total_shipping_notax 
    round($this_total_shipping_notax,4);
    ?>


    That should fix it.
  • Default avatar
    donald6    
     7 years ago
    0

    Error Solved!!!

    Thank you very much for your prompt, excellent support.