Skip to content

Commit

Permalink
add possibility to use custom filters on shopify (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
guitavano authored Aug 14, 2024
1 parent e5a1f53 commit 95960ff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shopify/utils/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const toPropertyValue = (
const isSelectedFilter = (filterValue: FilterValue, url: URL) => {
let isSelected = false;
url.searchParams.forEach((value, key) => {
if (!key.startsWith("filter")) return;
if (!key?.startsWith("filter")) return;
if (value === filterValue.label) isSelected = true;
});
return isSelected;
Expand Down
8 changes: 8 additions & 0 deletions shopify/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ export const getFiltersByUrl = (url: URL) => {
filters.push({ price: { min: Number(value) } });
} else if (key.startsWith("filter.v.price.lte")) {
filters.push({ price: { max: Number(value) } });
} else if (key.startsWith("filter.p.m.custom")) {
filters.push({
productMetafield: {
namespace: "custom",
key: key.replace("filter.p.m.custom.", ""),
value: value,
},
});
}
});
return filters;
Expand Down
1 change: 0 additions & 1 deletion vtex/utils/resourceRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export function resourceRange(
skip: number,
take: number,
Expand Down

0 comments on commit 95960ff

Please sign in to comment.