Title: DivisionByZeroError: Modulo by zero
Last modified: February 5, 2025

---

# DivisionByZeroError: Modulo by zero

 *  Resolved [wordpressdatasal](https://wordpress.org/support/users/wordpressdatasal/)
 * (@wordpressdatasal)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/divisionbyzeroerror-modulo-by-zero/)
 * Hello,
 * **WooCommerce Version: 9.6.1
   Silent Theme Version: 17.0.7
 * I am experiencing a WordPress Fatal Error related to “Uncaught DivisionByZeroError:
   Modulo by zero”:
 *     ```wp-block-code
       Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php:485 Stack trace: #0 /public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php(674): wc_get_loop_class() #1 /public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php(749): wc_get_product_class() #2 /public_html/wp-content/themes/salient/woocommerce/content-product.php(65): wc_product_class() #3 /public_html/wp-includes/template.php(812): require('/home/1122101.c...') #4 /public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(284): load_template() #5 /public_html/wp-content/plugins/woocommerce/templates/archive-product.php(62): wc_get_template_part() #6 /public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/home/1122101.c...') #7 /public_html/wp-content/plugins/woocommerce/templates/taxonomy-product-cat.php(22): wc_get_template() #8 /public_html/wp-includes/template-loader.php(106): include('/home/1122101.c...') #9 /public_html/wp-blog-header.php(19): require_once('/home/1122101.c...') #10 /public_html/index.php(17): require('/home/1122101.c...') #11 {main} thrown in /public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 485
       ```
   
 * I fixed it temporarily by editing wc-template-functions.php:
 *     ```wp-block-code
       function wc_get_loop_class() {	$loop_index = wc_get_loop_prop( 'loop', 0 );	$columns = absint( max( 1, wc_get_loop_prop( 'columns', wc_get_default_products_per_row() ) ) );if ($columns === 0) {    $columns = 1; // Zabezpieczenie przed dzieleniem przez zero}	++$loop_index;	wc_set_loop_prop( 'loop', $loop_index );	if ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) {		return 'first';	}	if ( 0 === $loop_index % $columns ) {		return 'last';	}	return '';}
       ```
   
 * I have already written to the theme creators.
 * Thanks
    -  This topic was modified 1 year, 4 months ago by [wordpressdatasal](https://wordpress.org/support/users/wordpressdatasal/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdivisionbyzeroerror-modulo-by-zero%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  [Moses M. (woo-hc)](https://wordpress.org/support/users/mosesmedh/)
 * (@mosesmedh)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/divisionbyzeroerror-modulo-by-zero/#post-18289280)
 * Hi [@wordpressdatasal](https://wordpress.org/support/users/wordpressdatasal/),
 * I’m glad to hear you were able to fix the issue with custom code. It seems like
   your theme might be using custom templates that override the default WooCommerce
   features. To confirm, could you switch to the default 2025 theme or the Storefront
   theme and let me know if the error persists or is resolved?

Viewing 1 replies (of 1 total)

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

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Moses M. (woo-hc)](https://wordpress.org/support/users/mosesmedh/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/divisionbyzeroerror-modulo-by-zero/#post-18289280)
 * Status: resolved