Title: DivisionByZeroError
Last modified: March 10, 2025

---

# DivisionByZeroError

 *  Resolved [orostegui](https://wordpress.org/support/users/orostegui/)
 * (@orostegui)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/divisionbyzeroerror/)
 * I have found an error in the file src/Integration/WooCommerce.php on line 816
 *     ```wp-block-code
       $discount = $discount / $item['quantity'] 
       ```
   
 * I have solved it simply by adding the validation if the discount is 0 do not 
   do the division
 *     ```wp-block-code
       if ($discount > 0) {  $discount = $discount / $item['quantity'];}
       ```
   
    -  This topic was modified 1 year, 2 months ago by [orostegui](https://wordpress.org/support/users/orostegui/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Torben Lundsgaard](https://wordpress.org/support/users/torbenlundsgaard/)
 * (@torbenlundsgaard)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/divisionbyzeroerror/#post-18354359)
 * That does not make sense. The only way that you can have division by zero is 
   if $item[‘quantity’] is zero. I’m not sure what the cause is when quantity is
   zero but i have the following check to prevent it in any case:
 *     ```wp-block-code
       if ( isset( $item['quantity'] ) && $item['quantity'] > 0 ) {    $discount = $discount / $item['quantity'];} else {  $discount = 0;}
       ```
   
 * It will be included in the next release
 *  Plugin Author [Torben Lundsgaard](https://wordpress.org/support/users/torbenlundsgaard/)
 * (@torbenlundsgaard)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/divisionbyzeroerror/#post-18354373)
 * The fix has been merged and will included in a release tomorrow. Thank you for
   bring this to my attention!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘DivisionByZeroError’ is closed to new replies.

 * ![](https://ps.w.org/gtm-kit/assets/icon.svg?rev=2783020)
 * [GTM Kit - Google Tag Manager & GA4 integration](https://wordpress.org/plugins/gtm-kit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gtm-kit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gtm-kit/)
 * [Active Topics](https://wordpress.org/support/plugin/gtm-kit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gtm-kit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gtm-kit/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Torben Lundsgaard](https://wordpress.org/support/users/torbenlundsgaard/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/divisionbyzeroerror/#post-18354373)
 * Status: resolved