WordPress.org

Forums

[resolved] [Plugin: WooCommerce] Warning: Division by zero (14 posts)

  1. johnsorci
    Member
    Posted 1 year ago #

    I am using WooCommerce with the Themeforest X Ultimate WordPress Theme.

    I cannot get the product thumbnails to show on the main shop page or any page. Instead I get this:

    Warning: Division by zero in /home/content/86/7154286/html/doodlesncompany/wp-content/plugins/woocommerce/templates/content-product.php on line 33
    
    Warning: Division by zero in /home/content/86/7154286/html/doodlesncompany/wp-content/plugins/woocommerce/templates/content-product.php on line 35

    When going into my files, these are the lines it is referencing:

    // Extra post classes
    $classes = array();
    if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] )
    	$classes[] = 'first';
    if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] )
    	$classes[] = 'last';
    ?>

    I have searched around for answers and nothing that I have found/tried has worked.

    Thanks for any help.

  2. johnsorci
    Member
    Posted 1 year ago #

    Figured it out.

  3. nestito
    Member
    Posted 1 year ago #

    Glad you found the resolution. What did it end up being? How did you fix it?

  4. gazza777
    Member
    Posted 1 year ago #

    What was the solution? I have the same issue.

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    @gazza777: If you require assistance then, as per the Forum Welcome, please post your own topic.

  6. gazza777
    Member
    Posted 1 year ago #

    Why would I open ANOTHER topic when my problem is EXACTLY the same?

  7. EedAbba
    Member
    Posted 1 year ago #

    I am not sure of the etiquette but I also need this resolved. Any tips would be appreciated. I don't complete understand PHP but I can edit it with some direction.

  8. tozq
    Member
    Posted 1 year ago #

    I have the same problem here too.

  9. tozq
    Member
    Posted 1 year ago #

    solved the problem.
    just disable all plugins and delete all products.

  10. tozq
    Member
    Posted 1 year ago #

    it is the "WooCommerce Customizer" cause the problem. Disable it everything ok.

  11. Tiresias28
    Member
    Posted 1 year ago #

    For those who are having the problem, you don't have to modify code or disable the plugin. Within the Customizer, there is a tab that gives WooCommerce Options. Just go in there, choose your settings, save, and the error will go away.

  12. Robey Lawrence
    Member
    Posted 1 year ago #

    @Tiresias28 Thank You!
    fixed for me.

    hmmm, I wonder what caused it to lose it's settings in the first place though. scary thought...

  13. imranpak
    Member
    Posted 8 months ago #

    @johnsorci

    Please share the solution, I am facing the same error.

    on WooCommerce website.

    If I commented this code:

    // Extra post classes
    $classes = array();
    if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] )
    $classes[] = 'first';
    if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] )
    $classes[] = 'last';

    And run the site still not working normally. As I uncommented the code and run the site, It works fine but it is not a solution.

    Please advise your test trick that resolve this issue.

    Grateful to you,

    Imran

  14. Priscilla
    Member
    Posted 7 months ago #

    For the sake of anyone who comes to this post looking for an answer I will make clear what is going on because what has been written here tells you the answer but not clearly.

    You do not need to edit any code. You just need to resave some settings.

    The issue comes from using a plugin called WooCommerce Product Archive Customiser

    For some reason when you get to a certain point as you work on your site, (not sure what sets it off) you will find that your Products settings for that plugin have been wiped out. The become blank!

    All you need to do is re-establish (re-save) your settings for that plugin which are found at: WooCommerce>Settings>Products> find the "Product Archives" heading on that page.

    Once you re-establish your settings, click save. The error goes away and your store products are just as before.

    If you are also using the WooCommerce Product Details Customiser plugin, (by the same author) you will also need to check and possibly re-establish "Product Details" settings too.

Topic Closed

This topic has been closed to new replies.

About this Topic