Product Variation Image Changing throws error with more than 30 variations

This topic has 4 replies, 2 voices, and was last updated 7 years, 11 months ago ago by Jack Richardson

  • Avatar: W00Ki3
    W00Ki3
    Participant
    May 9, 2016 at 16:24

    Hi,

    I am running Legenda theme version 2.11 and I *cannot* update it now. I am also running WooCommerce v2.5.5.

    On my products that have less than 30 variations, my product images change nicely when the color swatch is selected and all works well. However, when I have more than 30 product variations, the product images do not change and I get the following theme error thrown:

    Warning: Invalid argument supplied for foreach() in /nas/content/staging/yrcoclothing/wp-content/themes/legenda/framework/theme-functions.php on line 3249

    This is definitely an issue with the 30 product variations as I had one product with 31 variations. When I removed one of those, it started working perfectly.

    Can you please help me fix this issue?

    Thanks!

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 10, 2016 at 08:51

    Hello,

    Try to add this code in functions.php file in wp-content/themes/legenda directory:

    function custom_wc_ajax_variation_threshold( $qty, $product ) {
    	return 100;
    }
    
    add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 100, 2 );

    Best regards,
    Jack Richardson.

    Avatar: W00Ki3
    W00Ki3
    Participant
    May 10, 2016 at 16:29

    That worked perfectly!! Thank you!

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 10, 2016 at 17:18

    Hello,

    You’re welcome.

    Best regards,
    Jack Richardson.

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Product Variation Image Changing throws error with more than 30 variations’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.