WooCommerce Additional Variation Images 1.8.0 Release Notes

We released a new version of WooCommerce Additional Variation Images, this version packs some changes to the behavior, if you’re writing code that integrates with this plugin, read along.

The 1.8.0 fix release changes the way in which Additional Variation Images galleries are shown on product pages. This has resulted in a change to some of the jQuery event triggers available previously.

In the old version, when a variation was chosen on a products page, an Ajax event would be fired to find variation images, and then these images would be injected into the existing product gallery. The images that were there previously were removed and stored in memory—events were fired based on this ‘swapping’ of images.

The problem with this approach we found was that:

  • After swapping images, the gallery could fail to re-initialise.
  • Some scripts used in the gallery (Flexslider) would break if re-initialised on the same parent element.
  • Restoring the original gallery was overly complex due to the differences and complexities between the original gallery HTML on page load, and the HTML after Flexslider has initialised.

To avoid these issues, the new version does not manipulate gallery HTML, re-initialise components, or attempt to swap images. Instead, the HTML for a new gallery is inserted into the page, initialised once, and the old gallery is hidden from view (not removed from the page).

As well as fixing the original problem, there are some other side benefits to this approach including reduced complexity (no HTML needs to be directly manipulated), and no need to load the same variation images multiple times if variations are de-selected then re-selected; all galleries remain hidden on the page.

Developers need to be aware that as a result of these changes, some of the event triggers have been removed since they are no longer relevant. These include:

  • wc_additional_variation_images_frontend_on_reset
  • wc_additional_variation_images_frontend_on_reset_done
  • wc_additional_variation_images_frontend_image_swap_callback
  • wc_additional_variation_images_frontend_image_swap_done_callback
  • wc_additional_variation_images_frontend_ajax_default_image_swap_callback
  • wc_additional_variation_images_frontend_ajax_default_image_swap_done_callback
  • wc_additional_variation_images_frontend_reset_variation
  • wc_additional_variation_images_frontend_ajax_response_callback

The following events are still triggered in the new version:

  • wc_additional_variation_images_frontend_lightbox
  • wc_additional_variation_images_frontend_lightbox_done
  • wc_additional_variation_images_frontend_before_show_variation
  • wc_additional_variation_images_frontend_init

However, please note that these events were previously passed:

  • the gallery div class name
  • the main images div class name
  • the original gallery HTML
  • the original main images HTML

Since the gallery HTML is no longer manipulated, these values are no longer passed to the events.

To predict the impact of these changes we searched across https://wpdirectory.net/ and found no usage in plugins or themes of these events. GitHub revealed only a few instances of usage in themes, however, we noticed that these themes were also manipulating gallery HTML which is broken anyway, so since these events are no longer fired, the impact should be negligible.


Keep yourself in the loop!

Sign up for the WooCommerce developer newsletter:
Hidden
Hidden
Hidden


Leave a Reply

Your email address will not be published. Required fields are marked *