JS error: "Uncaught TypeError: Cannot read property 'oldPrice' of undefined"

This error happens because result will will end up being undefined if not all the possible swatch attributes have been filled in. I believe this is because $widget.options.jsonConfig.index only contains full "paths", where all swatch options have been selected, not partial paths.
A simple check of results's value will likely resolve the issue. I'm very new to Magento, so I'm not confident enough to assume this is the best approach.
Thanks!
Confirmed that it's happening on Magento 2.1.3
Hi guys,
Anyone found any solution yet?
Same error.
Also in 2.1.5 with sampledata!
@pat75007 The only solution I've found is to override swatch-renderer.js, and wrap the issue if statement in another if statement. This worked for my situation, but I don't know if it impacts any setups others may be using.
if (result && typeof result.oldPrice !== 'undefined') {
if (result.oldPrice.amount !== result.finalPrice.amount) {
$(this.options.slyOldPriceSelector).show();
} else {
$(this.options.slyOldPriceSelector).hide();
}
}
Hello. We reproduced this bug on version 2.1.3. But in develop version, that is 2.1.7 for Your case this very bug seems to be fixed as we have not been able to reproduce it on. So please let us now if You still can reproduce this issue on 2.1.7. Thank You.
@AlexWorking I believe we are experiencing this issue after updating from 2.1.2 to 2.1.7
swatch-renderer.js:714 Uncaught TypeError: Cannot read property 'oldPrice' of undefined
at $.(anonymous function).(anonymous function)._UpdatePrice (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/Magento_Swatches/js/swatch-renderer.js:714:23)
at $.(anonymous function).(anonymous function)._UpdatePrice (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/jquery/jquery-ui.js:402:25)
at $.(anonymous function).(anonymous function)._OnClick (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/Magento_Swatches/js/swatch-renderer.js:548:25)
at $.(anonymous function).(anonymous function)._OnClick (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/jquery/jquery-ui.js:402:25)
at HTMLDivElement.<anonymous> (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/Magento_Swatches/js/swatch-renderer.js:495:32)
at HTMLDivElement.dispatch (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/jquery.js:5226:27)
at HTMLDivElement.elemData.handle (https://www.screenshotsinc.com/pub/static/frontend/Magento/luma/en_US/jquery.js:4878:29)
Issue can be seen live @ https://www.screenshotsinc.com/gildan-adult-dryblend-50-50-t-shirt if that is any help.
Edit: Issue is no longer viewable at the live URL, as the work around @kfriend provided above seemed to do the trick.
This is also happening for us on Magento v2.1.7
Cannot read property 'oldPrice' of undefined in swatch-renderer.js:714
Still happening on 2.1.7. But seems to be fixed on 2.2, haven't tried it though..
Any update on this?
Hello @kfriend. Based on Your issue an internal issue were created - MAGETWO-70849. You'll be informed immediately after the issue is fixed. Thanks for reporting.
Duplicate of #7959
Patched in develop branch and 2.2 as MAGETWO-69541
Issue has been fixed in 2.2 and will be released very soon