Skip to content

OpenCart 3 - change main image with product option / variation image on click.

Notifications You must be signed in to change notification settings

VasetoSoft/opencart-3-product-variations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

OpenCart 3 Product Option / Variation - change main image with the product variation image.

This works with Electronic theme only!

Update Product View

OpenCart3\catalog\view\theme\electronic\template\product\product.twig

This is working for radio buttons, selects and checkboxes product options where the options is predefined and saved.

SELECT

<script type="text/javascript">
    // product-options - select
    $('.product-options select').change(function() {
        console.log($(this).prop('selectedIndex'));
        const idx = $(this).prop('selectedIndex');
        $('#product-imgs .slick-track .product-preview.slick-slide').not(".slick-cloned")[idx].click();
    });
</script>

RADIO BUTTONS

<script type="text/javascript">
    $('.product-options .radio input:radio').each(function(idx, elem) {
        console.log(idx);
        $(elem).on('click', function() {
            if($(this).is(':checked')) {
                $('#product-imgs .slick-track .product-preview.slick-slide').not(".slick-cloned")[idx + 1].click();
            }
        });
    });
</script>

CHECKBOXES - single checkbox only

<script type="text/javascript">
    
</script>

CHECKBOXES - Multiple checkboxes allowed

<script type="text/javascript">
    
</script>

About

OpenCart 3 - change main image with product option / variation image on click.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published