Title: Uncaught DivisionByZeroError: Division by zero
Last modified: December 19, 2024

---

# Uncaught DivisionByZeroError: Division by zero

 *  Resolved [Justin](https://wordpress.org/support/users/jtphelan/)
 * (@jtphelan)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/uncaught-divisionbyzeroerror-division-by-zero-2/)
 * I’m receiving this error at checkout when a product price is $0 the cart total
   is $0.
   _Uncaught DivisionByZeroError: Division by zero in /public\_html/stage/
   wp-content/plugins/preorders-for-woocommerce-pro/src/Cart.php:52_
 * It appears it’s trying to divide a percentage by the cart total which happens
   to be 0.
   LINE 52:
 *     ```wp-block-code
       $porcentage = $total_discount_for_coupons / WC()->cart->get_subtotal(); //
       ```
   
 * Changing it to this fixes the error for me.
 *     ```wp-block-code
       $porcentage = 0;if(WC()->cart->get_subtotal() > 0) {    $porcentage = $total_discount_for_coupons / WC()->cart->get_subtotal(); //}
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Support [mathdaniel](https://wordpress.org/support/users/mathdaniel/)
 * (@mathdaniel)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/uncaught-divisionbyzeroerror-division-by-zero-2/#post-18211248)
 * Hello,
 * I hope you are well.
 * First of all, thank you for the suggestion you provided. In this case, it is 
   noted that you are using the premium version. We can send you an official patch
   to resolve this conflict you are experiencing.
 * To ensure you receive the best possible assistance and access to official updates,
   we recommend contacting the official support channel. There, our team can assist
   you in more detail.
 * Best regards,
   Peace

Viewing 1 replies (of 1 total)

The topic ‘Uncaught DivisionByZeroError: Division by zero’ is closed to new replies.

 * ![](https://ps.w.org/pre-orders-for-woocommerce/assets/icon-256x256.gif?rev=2944662)
 * [Pre-Orders for WooCommerce](https://wordpress.org/plugins/pre-orders-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pre-orders-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pre-orders-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/pre-orders-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pre-orders-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pre-orders-for-woocommerce/reviews/)

## Tags

 * [division](https://wordpress.org/support/topic-tag/division/)
 * [uncaught](https://wordpress.org/support/topic-tag/uncaught/)
 * [zero](https://wordpress.org/support/topic-tag/zero/)

 * 1 reply
 * 2 participants
 * Last reply from: [mathdaniel](https://wordpress.org/support/users/mathdaniel/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/uncaught-divisionbyzeroerror-division-by-zero-2/#post-18211248)
 * Status: resolved