Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed JS undefined errors when application does not use the updated 4.2 views

Damian Legawiec15a87ea29958
diff --git a/frontend/app/assets/javascripts/spree/frontend/currency.js b/frontend/app/assets/javascripts/spree/frontend/currency.js
index 8b7ad051e3..9a84d51292 100644
--- a/frontend/app/assets/javascripts/spree/frontend/currency.js
+++ b/frontend/app/assets/javascripts/spree/frontend/currency.js
@@ -29,15 +29,17 @@ document.addEventListener('turbolinks:load', function(event) {
// fix back button issue with different currency set
// invalidate page if cached page has different currency then the current one
document.addEventListener('turbolinks:load', function(event) {
- if (SPREE_CURRENCY === SPREE_DEFAULT_CURRENCY) {
- var regexAnyCurrency = new RegExp('currency=')
- if (event.data.url.match(regexAnyCurrency) && !event.data.url.match(SPREE_CURRENCY)) {
- Spree.setCurrency(SPREE_CURRENCY)
- }
- } else {
- var regex = new RegExp('currency=' + SPREE_CURRENCY)
- if (!event.data.url.match(regex)) {
- Spree.setCurrency(SPREE_CURRENCY)
+ if (typeof (SPREE_DEFAULT_CURRENCY) !== 'undefined' && typeof (SPREE_CURRENCY) !== 'undefined') {
+ if (SPREE_CURRENCY === SPREE_DEFAULT_CURRENCY) {
+ var regexAnyCurrency = new RegExp('currency=')
+ if (event.data.url.match(regexAnyCurrency) && !event.data.url.match(SPREE_CURRENCY)) {
+ Spree.setCurrency(SPREE_CURRENCY)
+ }
+ } else {
+ var regex = new RegExp('currency=' + SPREE_CURRENCY)
+ if (!event.data.url.match(regex)) {
+ Spree.setCurrency(SPREE_CURRENCY)
+ }
}
}
})