This Wordpress plugin adds gallery to all Woocommerce product variations. When variation is switсhed in the frontend, plugin changes all gallery images using AJAX.
ipolikarpov/woocommerce-variation-gallery
Add gallery images to Woocommerce product variations and show it when user change variation in frontend
PHP