Product Image Doesn't Change When Select A Variant

Hey everyone! I recently came accross this issue where the variant option doesn’t make the product image change live, but the changes get applied when I reload the page.

{% unless product.options.size == 1 and product.variants[0].title == 'Default Title' %}
  {% for option in product.options_with_values %}
    {% assign option_index = forloop.index0 %}
    {%- capture option_id -%}
      single-option-{{ form_id }}-{{ option_index }}
    {%- endcapture -%}

    
      

        
        {{ option.values | first }}
        
      

    

  {% endfor %}
{% endunless %}

Is there any problem with this code do you think the main issue would be in the JavaScript file?

Anyone that could help?

Hello @batulkr ,

Can you please provide your store URL ?

This code is probably broken on any theme, because we have zero context about the theme.