Skip to content

Commit 3d1d3c5

Browse files
laugharnclaudevercel[bot]
authored
[template] align Shopify data layer (#306)
* [template] align Shopify operation error contract Standardize how lib/shopify/operations/* signal failure: transport and GraphQL errors always throw; missing resources return undefined/null/[]. Render-tolerant callers wrap with the new withFallback helper instead of operations swallowing errors internally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] inspect userErrors on every cart mutation Adds ShopifyUserError + unwrapCartMutation helpers so cart mutation responses are validated uniformly. Previously the line mutations (cartCreate, cartLinesAdd, cartLinesUpdate, cartLinesRemove) didn't select userErrors at all; the address/note mutations selected them but silently ignored them. Now any non-empty userErrors throws with the Shopify-provided messages, which the action wrappers surface as { success: false, error }. Also removes the dead if (!result) branches from lib/cart/action.ts that the new contract makes unreachable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] unify Shopify operation locale calling convention Convert the eight read operations that took positional (id, locale) arguments to a single params object, matching the convention already used by getCollections/getCatalogProducts/searchIndexProducts etc. Drops the unused _locale param from getMenu while we're here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] consolidate Shopify fragment and query locations Apply one rule: shared fragments live in fragments.ts; single-use queries are named top-level consts in the operation file; nothing is inlined inside shopifyFetch calls. - Move CART_FRAGMENT from cart.ts into fragments.ts and rewrite its inline money/image selections to reuse MoneyFields / ImageFields, matching the composition pattern used by PRODUCT_CARD_FRAGMENT et al. - Add COLLECTION_FIELDS_FRAGMENT shared by getCollection and getCollections, replacing the duplicated inline field selection. - Hoist all 11 inline cart queries/mutations and the 2 inline collection queries to top-level SCREAMING_SNAKE_CASE consts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] centralize cart cookie reads/writes Adds getCartIdFromCookie, setCartIdCookie, and buildCartIdSetCookieHeader to lib/cart/server.ts so the cookie name and attributes (HttpOnly, Secure, SameSite=Strict, 7-day Max-Age, Path=/) live in one place. Replaces 11 inline reads and one inline write in lib/shopify/operations/cart.ts and the manual Set-Cookie string construction in the chat route. While inlining, surfaced a latent type narrowing issue in the chat route's cart-create path — Cart.id is typed as string | undefined because optimistic client carts have no id, so the streaming Set-Cookie path now guards explicitly instead of template-literal'ing undefined. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] fix dead cache tag in getProductById The "product-id-${id}" tag is never pushed by app/api/webhooks/shopify or anywhere else — it invalidated nothing. Replace it with "product-${handle}" added after the fetch resolves, matching the format the webhook does push (so a Shopify product webhook now actually invalidates the by-id cache entry). The numeric-id tag via tagProducts already covered the admin_graphql_api_id webhook path; this restores the handle path too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [template] symmetric transform layout Move menu transforms (ShopifyMenuItem, ShopifyMenuResponse, transformShopifyMenu) from lib/shopify/operations/menu.ts to a new lib/shopify/transforms/menu.ts, matching every other resource (cart, collection, product, search). Push filter transformation inside getCollectionProducts and getSearchFacets. Both now accept an activeFilters param and return domain Filter[] + PriceRange? instead of raw ShopifyFilter[]. transformShopifyFilters loses its bogus default priceRange {0,1000} when no PRICE_RANGE filter exists — the optional return type now matches reality. 4 call sites stop running transformShopifyFilters themselves and stop maintaining the hasPriceRange workaround they used to detect the default. Filter sidebar and markdown generators already guard priceRange with truthy checks, so the behavior shift is visible only when Shopify returns no price filter at all: the price slider no longer renders a placeholder 0-1000 range. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix: The Storefront API docs describe an operation error-handling contract that is the exact inverse of the actual code after this PR This commit fixes the issue reported at apps/docs/content/docs/reference/storefront-api.mdx:163 BUG: The "Error handling" section of apps/docs/content/docs/reference/storefront-api.mdx (line ~163) states: "getCart() wraps the call in try-catch and returns undefined on failure, while getProduct() throws if the product isn't found." Both claims are now factually wrong: 1. getProduct() in apps/template/lib/shopify/operations/products.ts now does `if (!data.productByHandle) { return undefined; }` — it RETURNS undefined when the product is missing, it does not throw. 2. getCart() in apps/template/lib/shopify/operations/cart.ts no longer has any try/catch — it throws on transport/GraphQL failure and only returns undefined when there is genuinely no cart/cartId. Render-tolerant callers (components/nav/cart.tsx, app/cart/page.tsx, lib/cart/action.ts) now wrap the call in `withFallback(getCart(), undefined)` (defined in lib/shopify/errors.ts). This documents the opposite of the PR's headline error contract: operations throw on transport/GraphQL failure and return undefined/null/[] on missing, with withFallback for render-tolerant callers. Per repo guidelines, template feature changes that are documented must have their docs updated. The trigger is concrete: any reader following the docs would implement/expect the inverse error behavior. FIX: Rewrote the paragraph to describe the new contract — operations throw on transport/GraphQL failure and return undefined/null/[] when a resource is missing; getProduct() returns undefined when not found; getCart() returns undefined when there's no cart; and render paths use the withFallback(promise, fallback) helper to degrade gracefully. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com> Co-authored-by: laugharn <laugharn@gmail.com> * Fix: enable-shopify-menus skill shows broken getMenu copy-paste code using the old positional `getMenu("HANDLE", locale)` signature after getMenu was changed to a single object arg `getMenu({ handle })` with no locale This commit fixes the issue reported at packages/plugin/skills/enable-shopify-menus/SKILL.md:41 BUG: This PR changed `getMenu` in apps/template/lib/shopify/operations/menu.ts from the old positional signature `getMenu(handle: string, _locale: string = defaultLocale)` to a single object parameter `getMenu({ handle }: { handle: string }): Promise<Menu | null>`, removing the locale parameter entirely. However the `enable-shopify-menus` skill (packages/plugin/skills/enable-shopify-menus/SKILL.md lines 41 and 62) and its mirrored docs (apps/docs/content/docs/skills/enable-shopify-menus.mdx lines 52 and 73) still instruct users to copy-paste `const menu = await getMenu("NAV_HANDLE", locale);` and `const menu = await getMenu("FOOTER_HANDLE", locale);`. Concrete failure trigger: A user following the skill pastes `getMenu("NAV_HANDLE", locale)`. Under the new signature, this passes the string `"NAV_HANDLE"` as the destructured object argument (so `handle` becomes `undefined`), passes an unexpected second `locale` argument, and—in a TypeScript project—fails to compile because a string is not assignable to `{ handle: string }`. The resulting menu query runs with `handle: undefined`, returning no menu. So the skill produces broken, non-compiling code. Additionally, the `enable-shopify-markets` skill/docs ("update getMenu to derive country and language from the active locale") was inconsistent because getMenu no longer accepts a locale at all. FIX: Updated the four broken examples to the new object-arg form `getMenu({ handle: "NAV_HANDLE" })` / `getMenu({ handle: "FOOTER_HANDLE" })` in both the SKILL.md and the mirrored .mdx, keeping skill and docs in sync. Also reconciled the markets skill/docs guidance to state that getMenu currently takes only `{ handle }` and must be extended (e.g. `getMenu({ handle, locale })`) to add market scoping, rather than implying it already accepts a locale. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com> Co-authored-by: laugharn <laugharn@gmail.com> * [docs] update getProduct example to match current operation signature Two "this is the canonical operation pattern" code blocks still demonstrated the old positional getProduct(handle, locale) form. Update them to the params-object form, show the Promise<X | undefined> return type and the if (!data.X) return undefined missing-resource branch, so a reader copying the example gets the current contract. Also fix the @/lib/shopify/client import path in the REFERENCE.md example — that file was renamed to lib/shopify/fetch.ts on 2026-04-25 but the example never got updated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [docs] sync remaining lib/shopify/client references to fetch.ts Three places still referenced the old lib/shopify/client.ts path (renamed to fetch.ts on 2026-04-25). While in the CMS skill examples, also bring the example signatures up to the params-object convention from this PR — getHomepage({ locale }), getMarketingPage({ slug, locale }). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
1 parent 9093c74 commit 3d1d3c5

33 files changed

Lines changed: 704 additions & 609 deletions

File tree

apps/docs/content/docs/reference/storefront-api.mdx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ import { cacheLife, cacheTag } from "next/cache";
8989
import { shopifyFetch } from "../fetch";
9090
import { PRODUCT_FRAGMENT } from "../fragments";
9191
import { defaultLocale, getCountryCode, getLanguageCode } from "@/lib/i18n";
92-
93-
export async function getProduct(handle: string, locale: string = defaultLocale) {
92+
import type { ProductDetails } from "@/lib/types";
93+
94+
export async function getProduct({
95+
handle,
96+
locale = defaultLocale,
97+
}: {
98+
handle: string;
99+
locale?: string;
100+
}): Promise<ProductDetails | undefined> {
94101
"use cache";
95102
cacheLife("max");
96103
cacheTag("products", `product-${handle}`);
@@ -105,6 +112,8 @@ export async function getProduct(handle: string, locale: string = defaultLocale)
105112
},
106113
});
107114

115+
if (!data.productByHandle) return undefined;
116+
108117
return transformShopifyProductDetails(data.productByHandle);
109118
}
110119
```
@@ -160,7 +169,7 @@ The client handles errors at two levels:
160169

161170
**GraphQL errors** - if the response contains `errors` and no `data`, the client throws. If there are errors but `data` is also present (partial success), it logs a warning and returns the partial data.
162171

163-
Individual operations add their own handling on top. For example, `getCart()` wraps the call in try-catch and returns `undefined` on failure, while `getProduct()` throws if the product isn't found.
172+
Individual operations follow a consistent contract on top of this: they **throw** on transport or GraphQL failure, and **return** `undefined`/`null`/`[]` when a resource is simply missing. For example, `getProduct()` returns `undefined` when the product isn't found (rather than throwing), and `getCart()` returns `undefined` when there's no cart. For render paths that should degrade gracefully instead of crashing on a transport error, wrap the call in the `withFallback(promise, fallback)` helper — e.g. `withFallback(getCart(), undefined)` in the nav and cart page.
164173

165174
## Debug logging
166175

apps/docs/content/docs/skills/enable-shopify-cms.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@ Add Shopify metaobject-based CMS support to the shop template. This replaces the
6262
Implement three operations that return domain types from `lib/types.ts`:
6363

6464
```ts
65-
import { shopifyFetch } from "@/lib/shopify/client";
65+
import { defaultLocale } from "@/lib/i18n";
66+
import { shopifyFetch } from "@/lib/shopify/fetch";
6667
import type { Homepage, MarketingPage } from "@/lib/types";
6768

68-
export async function getHomepage(locale: string): Promise<Homepage | null> {
69+
export async function getHomepage({
70+
locale = defaultLocale,
71+
}: {
72+
locale?: string;
73+
} = {}): Promise<Homepage | null> {
6974
"use cache";
7075
cacheLife("max");
7176
cacheTag("cms-content");
7277
// Query cms_homepage metaobject, transform to Homepage type
7378
}
7479

75-
export async function getMarketingPage(
76-
slug: string,
77-
locale: string,
78-
): Promise<MarketingPage | null> {
80+
export async function getMarketingPage({
81+
slug,
82+
locale = defaultLocale,
83+
}: {
84+
slug: string;
85+
locale?: string;
86+
}): Promise<MarketingPage | null> {
7987
"use cache";
8088
cacheLife("max");
8189
cacheTag("cms-content");

apps/docs/content/docs/skills/enable-shopify-markets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export default getRequestConfig(async () => {
330330

331331
### Scope menu queries for markets
332332

333-
The base template keeps [`lib/shopify/operations/menu.ts`](../../lib/shopify/operations/menu.ts) unscoped so menus load before Shopify Markets is configured. When enabling markets, update `getMenu` to derive `country` and `language` from the active locale and query `menu` with `@inContext(country: $country, language: $language)`. Without that change, quick links and footer menu stay pinned to the default market. If the `enable-shopify-menus` skill has been run, the megamenu will also need this scoping.
333+
The base template keeps [`lib/shopify/operations/menu.ts`](../../lib/shopify/operations/menu.ts) unscoped (it takes only `{ handle }`) so menus load before Shopify Markets is configured. When enabling markets, extend `getMenu` to accept the active locale (e.g. `getMenu({ handle, locale })`), derive `country` and `language` from that locale, and query `menu` with `@inContext(country: $country, language: $language)`. Without that change, quick links and footer menu stay pinned to the default market. If the `enable-shopify-menus` skill has been run, the megamenu will also need this scoping.
334334

335335
---
336336

apps/docs/content/docs/skills/enable-shopify-menus.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { getMenu } from "@/lib/shopify/operations/menu";
4949
Inside `Nav`, replace `const items = navItems;` with:
5050

5151
```tsx
52-
const menu = await getMenu("NAV_HANDLE", locale);
52+
const menu = await getMenu({ handle: "NAV_HANDLE" });
5353
const items = menu?.items ?? navItems;
5454
```
5555

@@ -70,7 +70,7 @@ import { getMenu } from "@/lib/shopify/operations/menu";
7070
Change the signature to `async` and replace `const items = footerItems;` with:
7171

7272
```tsx
73-
const menu = await getMenu("FOOTER_HANDLE", locale);
73+
const menu = await getMenu({ handle: "FOOTER_HANDLE" });
7474
const items = menu?.items ?? footerItems;
7575
```
7676

apps/template/app/api/chat/route.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {
55
createUIMessageStreamResponse,
66
safeValidateUIMessages,
77
} from "ai";
8-
import { cookies } from "next/headers";
9-
108
import { createAgent, type PageContext, type User, withAgentContext } from "@/lib/agent/server";
9+
import { buildCartIdSetCookieHeader, getCartIdFromCookie } from "@/lib/cart/server";
1110
import { agent as agentConfig } from "@/lib/config";
1211
import { defaultLocale, type Locale } from "@/lib/i18n";
12+
import { withFallback } from "@/lib/shopify/errors";
1313
import { createCartWithoutCookie } from "@/lib/shopify/operations/cart";
1414
import { getCollection } from "@/lib/shopify/operations/collections";
1515
import { getProduct } from "@/lib/shopify/operations/products";
@@ -46,25 +46,15 @@ async function resolvePageContext(
4646
const pageType = segments[0];
4747

4848
if (pageType === "products" && segments.length >= 2) {
49-
try {
50-
const handle = segments[1];
51-
const product = await getProduct(handle, locale);
52-
return { type: "product", product };
53-
} catch {
54-
// Product not found — fall through to other branches.
55-
}
49+
const handle = segments[1];
50+
const product = await withFallback(getProduct({ handle, locale }), undefined);
51+
if (product) return { type: "product", product };
5652
}
5753

5854
if (pageType === "collections" && segments.length >= 2) {
59-
try {
60-
const handle = segments[1];
61-
const collection = await getCollection(handle, locale);
62-
if (collection) {
63-
return { type: "collection", handle, title: collection.title };
64-
}
65-
} catch {
66-
// Collection not found — fall through to other branches.
67-
}
55+
const handle = segments[1];
56+
const collection = await withFallback(getCollection({ handle, locale }), undefined);
57+
if (collection) return { type: "collection", handle, title: collection.title };
6858
}
6959

7060
if (pageType === "search") {
@@ -90,7 +80,6 @@ export async function POST(request: Request) {
9080
}
9181

9282
const body = await request.json();
93-
const store = await cookies();
9483
const { messages, chatId } = body;
9584

9685
if (!chatId) {
@@ -111,15 +100,15 @@ export async function POST(request: Request) {
111100
const page = await resolvePageContext(segments, locale, referer);
112101

113102
// Get or create cart before streaming (cookies can't be set during stream)
114-
let cartId = store.get("shopify_cartId")?.value;
103+
let cartId = await getCartIdFromCookie();
115104
let newCartCookie: string | undefined;
116105

117106
if (!cartId) {
118107
const newCart = await createCartWithoutCookie(locale);
119-
cartId = newCart.id;
120-
const secure = process.env.NODE_ENV === "production";
121-
const maxAge = 60 * 60 * 24 * 7; // 7 days
122-
newCartCookie = `shopify_cartId=${cartId}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${maxAge}${secure ? "; Secure" : ""}`;
108+
if (newCart.id) {
109+
cartId = newCart.id;
110+
newCartCookie = buildCartIdSetCookieHeader(newCart.id);
111+
}
123112
}
124113

125114
return withAgentContext(

apps/template/app/cart/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Page } from "@/components/ui/page";
1515
import { Sections } from "@/components/ui/sections";
1616
import type { Locale } from "@/lib/i18n";
1717
import { getLocale } from "@/lib/params";
18+
import { withFallback } from "@/lib/shopify/errors";
1819
import { getCart } from "@/lib/shopify/operations/cart";
1920

2021
export async function generateMetadata(): Promise<Metadata> {
@@ -41,7 +42,10 @@ export default async function CartPage() {
4142
}
4243

4344
async function CartContent({ locale }: { locale: Locale }) {
44-
const [cart, messages] = await Promise.all([getCart(), getMessages()]);
45+
const [cart, messages] = await Promise.all([
46+
withFallback(getCart(), undefined),
47+
getMessages(),
48+
]);
4549

4650
return (
4751
<NextIntlClientProvider messages={{ cart: messages.cart }}>

apps/template/app/collections/[handle]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function generateMetadata({
3030
}
3131

3232
const [collection, t] = await Promise.all([
33-
getCollection(handle, locale),
33+
getCollection({ handle, locale }),
3434
getTranslations("seo"),
3535
]);
3636

@@ -96,7 +96,7 @@ export default async function CollectionPage({
9696
if (handle === PLACEHOLDER_HANDLE) notFound();
9797
return handle;
9898
});
99-
const collectionPromise = handlePromise.then((handle) => getCollection(handle, locale));
99+
const collectionPromise = handlePromise.then((handle) => getCollection({ handle, locale }));
100100
const searchStatePromise = getCollectionSearchState(searchParams);
101101
const collectionResultsDataPromise = getCollectionResultsData({
102102
handlePromise,

apps/template/app/md/collections/[handle]/route.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
buildProductFiltersFromParams,
66
getCollectionProducts,
77
} from "@/lib/shopify/operations/products";
8-
import { transformShopifyFilters } from "@/lib/shopify/transforms/filters";
98
import { RESULTS_PER_PAGE, parseFiltersFromSearchParams, searchParamsToRecord } from "@/lib/utils";
109

1110
function markdownHeaders(cacheControl: string): HeadersInit {
@@ -29,8 +28,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ hand
2928

3029
try {
3130
const [collection, result] = await Promise.all([
32-
getCollection(handle, locale),
31+
getCollection({ handle, locale }),
3332
getCollectionProducts({
33+
activeFilters,
3434
collection: handle,
3535
sortKey: sort,
3636
limit: RESULTS_PER_PAGE,
@@ -50,13 +50,11 @@ export async function GET(request: Request, { params }: { params: Promise<{ hand
5050
);
5151
}
5252

53-
const transformedFilters = transformShopifyFilters(result.filters, { activeFilters });
54-
const hasPriceRange = result.filters.some((filter) => filter.type === "PRICE_RANGE");
5553
const markdown = collectionToMarkdown({
5654
collection,
5755
products: result.products,
58-
filters: transformedFilters.filters,
59-
priceRange: hasPriceRange ? transformedFilters.priceRange : undefined,
56+
filters: result.filters,
57+
priceRange: result.priceRange,
6058
activeFilters,
6159
pageInfo: result.pageInfo,
6260
locale,

apps/template/app/md/products/[handle]/route.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@ export async function GET(request: Request, { params }: { params: Promise<{ hand
88
const locale = resolveLocale(url.searchParams.get("locale") || defaultLocale);
99

1010
try {
11-
const product = await getProduct(handle, locale);
11+
const product = await getProduct({ handle, locale });
12+
13+
if (!product) {
14+
return new Response(
15+
`# Product Not Found\n\nThe product with handle \`${handle}\` could not be found.`,
16+
{
17+
status: 404,
18+
headers: {
19+
"Content-Type": "text/markdown; charset=utf-8",
20+
"Cache-Control": "public, max-age=3600, stale-while-revalidate=604800",
21+
Vary: "Accept",
22+
"X-Robots-Tag": "noindex",
23+
},
24+
},
25+
);
26+
}
27+
1228
const markdown = productToMarkdown(product, locale);
1329

1430
return new Response(markdown, {
@@ -19,21 +35,14 @@ export async function GET(request: Request, { params }: { params: Promise<{ hand
1935
"X-Robots-Tag": "noindex",
2036
},
2137
});
22-
} catch (error) {
23-
const message = error instanceof Error ? error.message : String(error);
24-
const isNotFound = message.includes("Product not found");
25-
38+
} catch {
2639
return new Response(
27-
isNotFound
28-
? `# Product Not Found\n\nThe product with handle \`${handle}\` could not be found.`
29-
: `# Server Error\n\nAn error occurred while retrieving the product. Please try again later.`,
40+
`# Server Error\n\nAn error occurred while retrieving the product. Please try again later.`,
3041
{
31-
status: isNotFound ? 404 : 500,
42+
status: 500,
3243
headers: {
3344
"Content-Type": "text/markdown; charset=utf-8",
34-
"Cache-Control": isNotFound
35-
? "public, max-age=3600, stale-while-revalidate=604800"
36-
: "no-cache, no-store, must-revalidate",
45+
"Cache-Control": "no-cache, no-store, must-revalidate",
3746
Vary: "Accept",
3847
"X-Robots-Tag": "noindex",
3948
},

apps/template/app/md/search/route.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
getSearchFacets,
66
searchIndexProducts,
77
} from "@/lib/shopify/operations/products";
8-
import { transformShopifyFilters } from "@/lib/shopify/transforms/filters";
98
import { RESULTS_PER_PAGE, parseFiltersFromSearchParams, searchParamsToRecord } from "@/lib/utils";
109

1110
function markdownHeaders(cacheControl: string): HeadersInit {
@@ -39,18 +38,16 @@ export async function GET(request: Request) {
3938
filters: shopifyFilters,
4039
locale,
4140
}),
42-
getSearchFacets({ query, collection, filters: shopifyFilters, locale }),
41+
getSearchFacets({ activeFilters, query, collection, filters: shopifyFilters, locale }),
4342
]);
4443

45-
const transformedFilters = transformShopifyFilters(facets.filters, { activeFilters });
46-
const hasPriceRange = facets.filters.some((filter) => filter.type === "PRICE_RANGE");
4744
const markdown = searchResultsToMarkdown({
4845
query,
4946
collection,
5047
products: results.products,
5148
total: facets.total,
52-
filters: transformedFilters.filters,
53-
priceRange: hasPriceRange ? transformedFilters.priceRange : undefined,
49+
filters: facets.filters,
50+
priceRange: facets.priceRange,
5451
activeFilters,
5552
pageInfo: results.pageInfo,
5653
locale,

0 commit comments

Comments
 (0)