Hello,
First of all, please remove all the customization. Our support does not cover fixing any customizations.
The theme has this option ready. There is an option to display the swatches as images which are set globally in “Image preview for this value” of the attribute item. The color from “Color preview for this value” should be cleared. In this case, the color, for example, =Red= would have one and the same image for all the products.
Or swatches may be presented as a featured image taken from product variations. This option is provided in the Theme Settings > Shop > Attribute swatches > Grid swatch attribute to display – choose pa_color (the color attribute, for example) and “Use images from product variations” should be enabled. The variable product should have featured image for each variation. In this case color, for example,= Red= would have the image taken from the product variation which is set for red variation.
Best Regards