From 269c2154db82e2c3a19f8ba9a36e9b249a745998 Mon Sep 17 00:00:00 2001 From: Andrii Holovan Date: Fri, 17 Mar 2017 12:48:10 +0200 Subject: [PATCH] Check of null result value in swatch-renderer.js There is an error when product has more than one kind of swatches: Uncaught TypeError: Cannot read property 'oldPrice' of undefined - swatch-renderer.js:843 Steps to reproduce: 1) Set Special Price for some Simple of the Configurable product which has more than one kind of swatches, for example SKU: WJ03 2) Go to PDP (../augusta-pullover-jacket.html) 3) Select some Color and look to the console - there You will be able to see the error. This is because 'result' is null before all of the swatches are selected. --- .../Magento/Swatches/view/frontend/web/js/swatch-renderer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index ed0933c77e897..1148e69c265c0 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -840,13 +840,13 @@ define([ } ); - if (result.oldPrice.amount !== result.finalPrice.amount) { + if (typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount) { $(this.options.slyOldPriceSelector).show(); } else { $(this.options.slyOldPriceSelector).hide(); } - if (result.tierPrices.length) { + if (typeof result != 'undefined' && result.tierPrices.length) { if (this.options.tierPriceTemplate) { tierPriceHtml = mageTemplate( this.options.tierPriceTemplate,