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 filters JS code

Damian Legawiecf643dd36e5ee
diff --git a/frontend/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 b/frontend/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6
index 77bb64e375..997a4e9f76 100644
--- a/frontend/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6
+++ b/frontend/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6
@@ -33,12 +33,16 @@ Spree.ready(function() {
// we have 2 elements for filtering prices - desktop and mobile
const desktopElement = document.getElementById('filterPriceRangeDesktop')
- const desktopFilterButton = desktopElement.querySelector('a')
- const desktopPriceRangeFilter = new PriceRangeFilter(desktopElement, desktopFilterButton)
- desktopPriceRangeFilter.handlePriceChange()
+ if (desktopElement) {
+ const desktopFilterButton = desktopElement.querySelector('a')
+ const desktopPriceRangeFilter = new PriceRangeFilter(desktopElement, desktopFilterButton)
+ desktopPriceRangeFilter.handlePriceChange()
+ }
const mobileElement = document.getElementById('filterPriceRangeMobile')
- const mobileFilterButton = document.getElementById('filterProductsButtonMobile')
- const mobilePriceRangeFilter = new PriceRangeFilter(mobileElement, mobileFilterButton)
- mobilePriceRangeFilter.handlePriceChange()
+ if (mobileElement) {
+ const mobileFilterButton = document.getElementById('filterProductsButtonMobile')
+ const mobilePriceRangeFilter = new PriceRangeFilter(mobileElement, mobileFilterButton)
+ mobilePriceRangeFilter.handlePriceChange()
+ }
});