From 131cd6c7e0028e54afb2e279662a7e91877e489c Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 14 Feb 2017 16:56:26 +0100 Subject: [PATCH] [FIX] website_sale: update zoomed image on variant When we select a variant on a product page on the eCommerce, this can change the product image. With this commit the change is also reverberated to the picture displayed by the zooming feature. opw-708089 --- addons/website_sale/static/src/js/website_sale.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 1bb49194f37..11e26de4f6b 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -247,9 +247,9 @@ odoo.define('website_sale.website_sale', function (require) { $img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id) .data('oe-model', 'product.product').data('oe-id', product_id); - $img = $(event_source).closest('tr.js_product, .oe_website_sale').find('img.js_variant_img_small'); - if ($img) { // if only one, thumbnails are not displayed - $img.attr("src", "/web/image/product.product/" + product_id + "/image/90x90"); + var $thumbnail = $(event_source).closest('tr.js_product, .oe_website_sale').find('img.js_variant_img_small'); + if ($thumbnail.length !== 0) { // if only one, thumbnails are not displayed + $thumbnail.attr("src", "/web/image/product.product/" + product_id + "/image/90x90"); $('.carousel').carousel(0); } } @@ -259,6 +259,11 @@ odoo.define('website_sale.website_sale', function (require) { $img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id) .data('oe-model', 'product.product').data('oe-id', product_id); } + // reset zooming constructs + $img.filter('[data-zoom-image]').attr('data-zoom-image', $img.attr('src')); + if ($img.data('zoomOdoo') !== undefined) { + $img.data('zoomOdoo').isReady = false; + } } $(oe_website_sale).on('change', 'input.js_product_change', function () {