Skip to content

Commit 269c215

Browse files
authored
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.
1 parent 5f7064f commit 269c215

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,13 +840,13 @@ define([
840840
}
841841
);
842842

843-
if (result.oldPrice.amount !== result.finalPrice.amount) {
843+
if (typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount) {
844844
$(this.options.slyOldPriceSelector).show();
845845
} else {
846846
$(this.options.slyOldPriceSelector).hide();
847847
}
848848

849-
if (result.tierPrices.length) {
849+
if (typeof result != 'undefined' && result.tierPrices.length) {
850850
if (this.options.tierPriceTemplate) {
851851
tierPriceHtml = mageTemplate(
852852
this.options.tierPriceTemplate,

0 commit comments

Comments
 (0)