|
|
@@ -42,7 +42,18 @@ function getAllCollection(data) {
|
|
42
|
42
|
function getSelectedCollectionTitles() {
|
|
43
|
43
|
const storedCollections = sessionStorage.getItem("amber-select-collections");
|
|
44
|
44
|
|
|
45
|
|
- if (!storedCollections) return [];
|
|
|
45
|
+ if (!storedCollections) {
|
|
|
46
|
+ const storedCollection = sessionStorage.getItem("amber-select-collection");
|
|
|
47
|
+
|
|
|
48
|
+ if (!storedCollection) return [];
|
|
|
49
|
+
|
|
|
50
|
+ try {
|
|
|
51
|
+ const collection = JSON.parse(storedCollection);
|
|
|
52
|
+ return collection?.title ? [collection.title] : [];
|
|
|
53
|
+ } catch (error) {
|
|
|
54
|
+ return [];
|
|
|
55
|
+ }
|
|
|
56
|
+ }
|
|
46
|
57
|
|
|
47
|
58
|
try {
|
|
48
|
59
|
const collectionTitles = JSON.parse(storedCollections);
|
|
|
@@ -159,10 +170,6 @@ const ProductList = ({ size = 99999 }) => {
|
|
159
|
170
|
|
|
160
|
171
|
// Collection
|
|
161
|
172
|
newFilteredProducts = newFilteredProducts.filter((product) => {
|
|
162
|
|
- // Product list now follows collections exposed by the Shopify collection
|
|
163
|
|
- // custom.menu_group metafield.
|
|
164
|
|
- if (!productHasVisibleCollection(product)) return false;
|
|
165
|
|
-
|
|
166
|
173
|
if (selectedCollectionTitles.length > 0) {
|
|
167
|
174
|
return (
|
|
168
|
175
|
productMatchesSelectedType(product) &&
|
|
|
@@ -172,12 +179,18 @@ const ProductList = ({ size = 99999 }) => {
|
|
172
|
179
|
);
|
|
173
|
180
|
}
|
|
174
|
181
|
|
|
|
182
|
+ // Product list now follows collections exposed by the Shopify collection
|
|
|
183
|
+ // custom.menu_group metafield.
|
|
|
184
|
+ if (!productHasVisibleCollection(product)) return false;
|
|
|
185
|
+
|
|
175
|
186
|
if (collection == "all" || collection == "collection") {
|
|
176
|
187
|
return productMatchesSelectedType(product);
|
|
177
|
188
|
} else {
|
|
178
|
189
|
return (
|
|
179
|
190
|
productMatchesSelectedType(product) &&
|
|
180
|
|
- product.collections.some((data) => data?.title === collection)
|
|
|
191
|
+ product.collections.some((data) =>
|
|
|
192
|
+ normalizeTitle(data?.title || "") === normalizeTitle(collection)
|
|
|
193
|
+ )
|
|
181
|
194
|
);
|
|
182
|
195
|
}
|
|
183
|
196
|
});
|