WooCommerce 3.3.3 Broken Product Page Display

My shop products all displayed fine I believe until today just after I upgraded WooCommerce to v 3.3.3.

Now, most of the products already listed work fine but some don’t load the entire page - looking in the HTML, the page loading stops while rendering a list under the section ‘related products’.

A quick check and it seems any product not on its own in a category is affected in this way.

This is killing much of the functionality of the rest of the page. There’s no error messages displayed.

Any ideas?

Additional.

I found this PHP error is occurring each time one of these broken product pages is loaded:

[23-Feb-2018 10:13:27 UTC] PHP Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /home/my_account_folder/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php:388

OK I fixed it. It’s a problem in WooCommerce I believe as opposed to X.

I found the code at the previously specified location and edited it from:

if ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) 
{
	return 'first';
} 
elseif ( 0 === $loop_index % $columns ) 
{
	return 'last';
} 
else 
{
	return '';
}

to:

	if ($columns <= 0)
	{
		return '';
	}
	elseif ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) 
	{
		return 'first';
	} 
	elseif ( 0 === $loop_index % $columns ) 
	{
		return 'last';
	} 
	else 
	{
		return '';
	}

Thanks for sharing the solution!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.