'Prestashop 1.7.7.2 - Product variations Images dont change not completly

I'm using Prestashop version 1.7.8.5

I've update the tpl all replacing with "product-cover-thumbnails.tpl"

// line 28 {if $product.cover}

// replace by {if $product.default_image}

It's work great on the following developer test url

the only issue is the modal that not swosing the proper image but just the default attribute

in the modal box

do you have a any suggestion ??

I'm using this theme

https://prestahero.com/it/elettronica-e-computer/104-amazonas.html

This is my develop test url

https://dev.nutripoint24.ch/shop/it/barrette-energetiche/14-energy-oatsnack-15x6570g[enter link description here]2

enter image description here

enter image description here

I've also sent the two different image of the product just the second one products image it is correct ...

Anybody can suggest to me the proper php tpl correction

Thank you so much

@Paolo Cheers



Solution 1:[1]

Two approaches:

  1. String Concatenation

    $('select option[value="'+lastword+'"]')
    
  2. Variable injection

    $(`select option[value="${lastword}"]`)
    

(You need to use ` instead of ')

Solution 2:[2]

Use template literals (using backticks ``)

 $(`select option[value="${lastword}"]`).attr("selected","selected");

Solution 3:[3]

You can use

$('select option[value=' + lastword + ']').attr("selected","selected");

Solution 4:[4]

change this line

$('select option[value=" + this.lastword +"]').attr("selected","selected");

to this

$('select option[value="' + lastword + '"]').attr("selected","selected");

lastword is a local variable. you cannot use it as this.lastword.

and if you want to use it inline the use backticks

$(`select option[value="${lastword}"]`).attr("selected","selected");

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danbardo
Solution 2
Solution 3 Cheng Adrian
Solution 4