diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dcf2ee3e2..ea1bd538ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Draft +- Fix `onThemeBundleMain` binding to `window` load instead of script element, guard `optionChangeDecorator` against null response on error, and fix `updateWalletButtonsView` crash on cart edit modal [#2615](https://github.com/bigcommerce/cornerstone/pull/2615) - Add to Cart and quantity buttons disabled when BCData is empty [#2612](https://github.com/bigcommerce/cornerstone/pull/2612) - Introduce strikethrough display for discounted shipping quote prices on cart page [#2611](https://github.com/bigcommerce/cornerstone/pull/2611) - Render native language names on storefront using Intl.DisplayNames [#2607](https://github.com/bigcommerce/cornerstone/pull/2607) diff --git a/assets/js/theme/common/product-details-base.js b/assets/js/theme/common/product-details-base.js index c2c9c8a550..5c4588737d 100644 --- a/assets/js/theme/common/product-details-base.js +++ b/assets/js/theme/common/product-details-base.js @@ -17,6 +17,7 @@ const optionsTypesMap = { export function optionChangeDecorator(areDefaultOptionsSet) { return (err, response) => { + if (err) return; const attributesData = response.data || {}; const attributesContent = response.content || {}; @@ -393,7 +394,7 @@ export default class ProductDetailsBase { updateWalletButtonsView(data) { const viewModel = this.getViewModel(this.$scope); - const isValidForm = viewModel.$addToCartForm[0].checkValidity(); + const isValidForm = viewModel.$addToCartForm?.[0]?.checkValidity() ?? true; this.toggleWalletButtonsVisibility(isValidForm && data.purchasable && data.instock); } diff --git a/templates/layout/base.html b/templates/layout/base.html index 6bbb2dae19..60f2442c0e 100644 --- a/templates/layout/base.html +++ b/templates/layout/base.html @@ -85,7 +85,11 @@ const scriptElement = document.getElementById('theme-bundle-main'); if (scriptElement) { - addEventListener('load', onThemeBundleMain); + if (typeof window.stencilBootstrap === 'function') { + onThemeBundleMain(); + } else { + scriptElement.addEventListener('load', onThemeBundleMain, { once: true }); + } } else { console.error('Could not find script element with id "theme-bundle-main"'); }