@bacano/sdk 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -490,6 +490,12 @@ var GET_PRODUCTS = (
490
490
  id
491
491
  name
492
492
  description
493
+ product_website_publications(
494
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
495
+ limit: 1
496
+ ) {
497
+ show_when_out_of_stock
498
+ }
493
499
  long_description
494
500
  slug
495
501
  seo_title
@@ -725,6 +731,12 @@ var GET_PRODUCT_BY_PK = (
725
731
  limit: 1
726
732
  ) {
727
733
  id
734
+ product_website_publications(
735
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
736
+ limit: 1
737
+ ) {
738
+ show_when_out_of_stock
739
+ }
728
740
  product_option_group_members(limit: 1) {
729
741
  group {
730
742
  id
@@ -974,6 +986,12 @@ var GET_PRODUCT_SEO_ENTRIES = (
974
986
  id
975
987
  name
976
988
  slug
989
+ product_website_publications(
990
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
991
+ limit: 1
992
+ ) {
993
+ show_when_out_of_stock
994
+ }
977
995
  seo_title
978
996
  seo_description
979
997
  seo_image_file_id
@@ -2607,6 +2625,7 @@ var GET_PRODUCT_FILTERS = (
2607
2625
  query GetProductFilters(
2608
2626
  $companyId: uuid!
2609
2627
  $chainId: uuid!
2628
+ $websiteId: uuid!
2610
2629
  $where: products_bool_exp = {}
2611
2630
  $attributeListKey: String!
2612
2631
  ) {
@@ -2614,6 +2633,12 @@ var GET_PRODUCT_FILTERS = (
2614
2633
  where: {
2615
2634
  _and: [
2616
2635
  { company_id: { _eq: $companyId } }
2636
+ {
2637
+ product_website_publications: {
2638
+ website_id: { _eq: $websiteId }
2639
+ is_visible: { _eq: true }
2640
+ }
2641
+ }
2617
2642
  {
2618
2643
  chain_products: {
2619
2644
  chain_id: { _eq: $chainId }
@@ -2626,6 +2651,12 @@ var GET_PRODUCT_FILTERS = (
2626
2651
  }
2627
2652
  ) {
2628
2653
  id
2654
+ product_website_publications(
2655
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
2656
+ limit: 1
2657
+ ) {
2658
+ show_when_out_of_stock
2659
+ }
2629
2660
  category
2630
2661
  subcategory
2631
2662
  color
@@ -2733,6 +2764,7 @@ var GET_SEARCH_SUGGESTIONS = (
2733
2764
  query GetSearchSuggestions(
2734
2765
  $companyId: uuid!
2735
2766
  $chainId: uuid!
2767
+ $websiteId: uuid!
2736
2768
  $term: String!
2737
2769
  $productLimit: Int = 5
2738
2770
  $brandLimit: Int = 3
@@ -2740,6 +2772,10 @@ var GET_SEARCH_SUGGESTIONS = (
2740
2772
  products(
2741
2773
  where: {
2742
2774
  company_id: { _eq: $companyId }
2775
+ product_website_publications: {
2776
+ website_id: { _eq: $websiteId }
2777
+ is_visible: { _eq: true }
2778
+ }
2743
2779
  chain_products: {
2744
2780
  chain_id: { _eq: $chainId }
2745
2781
  is_enabled: { _eq: true }
@@ -2752,6 +2788,29 @@ var GET_SEARCH_SUGGESTIONS = (
2752
2788
  ) {
2753
2789
  id
2754
2790
  name
2791
+ product_website_publications(
2792
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
2793
+ limit: 1
2794
+ ) {
2795
+ show_when_out_of_stock
2796
+ }
2797
+ product_variants(where: { is_disabled: { _eq: false } }) {
2798
+ id
2799
+ product_variant_prices(
2800
+ where: {
2801
+ price_type: { _eq: CLIENT }
2802
+ _or: [
2803
+ { chain_id: { _eq: $chainId } }
2804
+ { chain_id: { _is_null: true } }
2805
+ ]
2806
+ }
2807
+ ) {
2808
+ id
2809
+ price
2810
+ price_type
2811
+ chain_id
2812
+ }
2813
+ }
2755
2814
  }
2756
2815
  brands(
2757
2816
  where: {
@@ -3911,6 +3970,7 @@ function mapProduct(raw, storageUrl, labels, chainId) {
3911
3970
  createdAt: raw.created_at,
3912
3971
  updatedAt: raw.updated_at ?? raw.created_at,
3913
3972
  variants,
3973
+ outOfStockVisibilityOverride: raw.product_website_publications?.[0]?.show_when_out_of_stock ?? null,
3914
3974
  detailVariants,
3915
3975
  media: raw.product_media.map((m) => mapMedia(m, storageUrl)),
3916
3976
  attributes: raw.product_attributes.map(
@@ -4272,7 +4332,7 @@ async function getWebsiteAvailabilityByVariantId(graphqlUrl, getHeaders, variant
4272
4332
  }
4273
4333
  return availabilityByVariantId;
4274
4334
  }
4275
- async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
4335
+ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false, onlyInStock = false) {
4276
4336
  const variantIds = products.flatMap(
4277
4337
  (product) => product.variants.map((variant) => variant.id)
4278
4338
  );
@@ -4298,11 +4358,11 @@ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, c
4298
4358
  pricing: resolveProductPricing(prices)
4299
4359
  };
4300
4360
  }).filter(
4301
- (variant) => inStockVariantIds.has(variant.id) && variant.pricing.currentPrice != null
4361
+ (variant) => (inStockVariantIds.has(variant.id) || !onlyInStock && (product.outOfStockVisibilityOverride ?? showOutOfStockByDefault)) && variant.pricing.currentPrice != null
4302
4362
  )
4303
4363
  })).filter((product) => product.variants.length > 0);
4304
4364
  }
4305
- async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
4365
+ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false) {
4306
4366
  const variantIds = products.flatMap(
4307
4367
  (product) => product.product_variants.map((variant) => variant.id)
4308
4368
  );
@@ -4324,7 +4384,7 @@ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products
4324
4384
  const pricing = resolveProductPricing(
4325
4385
  selectPublicPrices(prices, chainId)
4326
4386
  );
4327
- return inStockVariantIds.has(variant.id) && pricing.currentPrice != null;
4387
+ return (inStockVariantIds.has(variant.id) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? showOutOfStockByDefault)) && pricing.currentPrice != null;
4328
4388
  })
4329
4389
  );
4330
4390
  }
@@ -4395,7 +4455,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4395
4455
  getHeaders,
4396
4456
  [mappedProduct],
4397
4457
  ctx.chainId,
4398
- ctx.websiteId
4458
+ ctx.websiteId,
4459
+ ctx.config?.show_out_of_stock_products === true
4399
4460
  );
4400
4461
  if (!filteredProducts[0]) return null;
4401
4462
  const specifications = await loadProductSpecifications([product.id]);
@@ -4628,7 +4689,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4628
4689
  getHeaders,
4629
4690
  data.products ?? [],
4630
4691
  ctx.chainId,
4631
- ctx.websiteId
4692
+ ctx.websiteId,
4693
+ ctx.config?.show_out_of_stock_products === true
4632
4694
  );
4633
4695
  const entries = availableProducts.slice(0, limit).map((product) => mapProductSeoEntry(product, storageUrl)).filter((entry) => Boolean(entry));
4634
4696
  return {
@@ -4705,7 +4767,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4705
4767
  (p) => mapProduct(p, storageUrl, publicAttributeLabels, chainId)
4706
4768
  ),
4707
4769
  chainId,
4708
- ctx.websiteId
4770
+ ctx.websiteId,
4771
+ ctx.config?.show_out_of_stock_products === true,
4772
+ opts?.inStock === true
4709
4773
  );
4710
4774
  const specifications = await loadProductSpecifications(
4711
4775
  products.map((product) => product.id)
@@ -4812,6 +4876,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4812
4876
  {
4813
4877
  companyId: ctx.companyId,
4814
4878
  chainId,
4879
+ websiteId: ctx.websiteId,
4815
4880
  attributeListKey: DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
4816
4881
  where: buildProductWhere(opts.filters ?? {}, chainId)
4817
4882
  },
@@ -4835,7 +4900,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4835
4900
  variant.product_variant_prices.map(mapPrice),
4836
4901
  chainId
4837
4902
  );
4838
- return prices.length > 0 && (availabilityByVariantId.get(variant.id)?.inStock ?? false);
4903
+ return prices.length > 0 && ((availabilityByVariantId.get(variant.id)?.inStock ?? false) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true));
4839
4904
  });
4840
4905
  if (!hasVisibleVariant) continue;
4841
4906
  applicableCategories.add(product.category);
@@ -4923,6 +4988,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4923
4988
  {
4924
4989
  companyId: ctx.companyId,
4925
4990
  chainId,
4991
+ websiteId: ctx.websiteId,
4926
4992
  attributeListKey: opts?.attributeListKey ?? DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
4927
4993
  where: {
4928
4994
  ...opts?.categoryName ? { category: { _eq: opts.categoryName } } : {},
@@ -4977,7 +5043,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4977
5043
  chainId
4978
5044
  ),
4979
5045
  inStock: availabilityByVariantId.get(variant.id)?.inStock ?? false
4980
- })).filter((variant) => variant.inStock && variant.prices.length > 0);
5046
+ })).filter(
5047
+ (variant) => (variant.inStock || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true)) && variant.prices.length > 0
5048
+ );
4981
5049
  if (visibleVariants.length === 0) continue;
4982
5050
  categoryCounts.set(
4983
5051
  product.category,
@@ -5062,6 +5130,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
5062
5130
  "NO_CHAIN"
5063
5131
  );
5064
5132
  }
5133
+ const chainId = ctx.chainId;
5065
5134
  const term = `%${opts.query}%`;
5066
5135
  const limit = opts.limit ?? 8;
5067
5136
  const data = await executeGraphQL(
@@ -5069,7 +5138,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
5069
5138
  GET_SEARCH_SUGGESTIONS,
5070
5139
  {
5071
5140
  companyId: ctx.companyId,
5072
- chainId: ctx.chainId,
5141
+ chainId,
5142
+ websiteId: ctx.websiteId,
5073
5143
  term,
5074
5144
  productLimit: Math.min(limit, 5),
5075
5145
  brandLimit: Math.max(limit - 5, 3)
@@ -5077,8 +5147,29 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
5077
5147
  getHeaders
5078
5148
  );
5079
5149
  const suggestions = [];
5150
+ const availability = await getWebsiteAvailabilityByVariantId(
5151
+ graphqlUrl,
5152
+ getHeaders,
5153
+ (data.products ?? []).flatMap(
5154
+ (product) => product.product_variants.map((variant) => variant.id)
5155
+ ),
5156
+ chainId,
5157
+ ctx.websiteId
5158
+ );
5080
5159
  for (const p of data.products ?? []) {
5081
- suggestions.push({ type: "product", text: p.name, id: p.id });
5160
+ const showWithoutStock = p.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true;
5161
+ const isVisible = p.product_variants.some((variant) => {
5162
+ const hasPrice = resolveProductPricing(
5163
+ selectPublicPrices(
5164
+ variant.product_variant_prices.map(mapPrice),
5165
+ chainId
5166
+ )
5167
+ ).currentPrice != null;
5168
+ return hasPrice && (showWithoutStock || availability.get(variant.id)?.inStock === true);
5169
+ });
5170
+ if (isVisible) {
5171
+ suggestions.push({ type: "product", text: p.name, id: p.id });
5172
+ }
5082
5173
  }
5083
5174
  for (const b of data.brands ?? []) {
5084
5175
  suggestions.push({ type: "brand", text: b.name, id: b.id });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacano/sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "TypeScript SDK for building websites on the Bacano ERP",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
package/react.cjs CHANGED
@@ -259,6 +259,12 @@ var GET_PRODUCTS = (
259
259
  id
260
260
  name
261
261
  description
262
+ product_website_publications(
263
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
264
+ limit: 1
265
+ ) {
266
+ show_when_out_of_stock
267
+ }
262
268
  long_description
263
269
  slug
264
270
  seo_title
@@ -494,6 +500,12 @@ var GET_PRODUCT_BY_PK = (
494
500
  limit: 1
495
501
  ) {
496
502
  id
503
+ product_website_publications(
504
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
505
+ limit: 1
506
+ ) {
507
+ show_when_out_of_stock
508
+ }
497
509
  product_option_group_members(limit: 1) {
498
510
  group {
499
511
  id
@@ -743,6 +755,12 @@ var GET_PRODUCT_SEO_ENTRIES = (
743
755
  id
744
756
  name
745
757
  slug
758
+ product_website_publications(
759
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
760
+ limit: 1
761
+ ) {
762
+ show_when_out_of_stock
763
+ }
746
764
  seo_title
747
765
  seo_description
748
766
  seo_image_file_id
@@ -2376,6 +2394,7 @@ var GET_PRODUCT_FILTERS = (
2376
2394
  query GetProductFilters(
2377
2395
  $companyId: uuid!
2378
2396
  $chainId: uuid!
2397
+ $websiteId: uuid!
2379
2398
  $where: products_bool_exp = {}
2380
2399
  $attributeListKey: String!
2381
2400
  ) {
@@ -2383,6 +2402,12 @@ var GET_PRODUCT_FILTERS = (
2383
2402
  where: {
2384
2403
  _and: [
2385
2404
  { company_id: { _eq: $companyId } }
2405
+ {
2406
+ product_website_publications: {
2407
+ website_id: { _eq: $websiteId }
2408
+ is_visible: { _eq: true }
2409
+ }
2410
+ }
2386
2411
  {
2387
2412
  chain_products: {
2388
2413
  chain_id: { _eq: $chainId }
@@ -2395,6 +2420,12 @@ var GET_PRODUCT_FILTERS = (
2395
2420
  }
2396
2421
  ) {
2397
2422
  id
2423
+ product_website_publications(
2424
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
2425
+ limit: 1
2426
+ ) {
2427
+ show_when_out_of_stock
2428
+ }
2398
2429
  category
2399
2430
  subcategory
2400
2431
  color
@@ -2502,6 +2533,7 @@ var GET_SEARCH_SUGGESTIONS = (
2502
2533
  query GetSearchSuggestions(
2503
2534
  $companyId: uuid!
2504
2535
  $chainId: uuid!
2536
+ $websiteId: uuid!
2505
2537
  $term: String!
2506
2538
  $productLimit: Int = 5
2507
2539
  $brandLimit: Int = 3
@@ -2509,6 +2541,10 @@ var GET_SEARCH_SUGGESTIONS = (
2509
2541
  products(
2510
2542
  where: {
2511
2543
  company_id: { _eq: $companyId }
2544
+ product_website_publications: {
2545
+ website_id: { _eq: $websiteId }
2546
+ is_visible: { _eq: true }
2547
+ }
2512
2548
  chain_products: {
2513
2549
  chain_id: { _eq: $chainId }
2514
2550
  is_enabled: { _eq: true }
@@ -2521,6 +2557,29 @@ var GET_SEARCH_SUGGESTIONS = (
2521
2557
  ) {
2522
2558
  id
2523
2559
  name
2560
+ product_website_publications(
2561
+ where: { website_id: { _eq: $websiteId }, is_visible: { _eq: true } }
2562
+ limit: 1
2563
+ ) {
2564
+ show_when_out_of_stock
2565
+ }
2566
+ product_variants(where: { is_disabled: { _eq: false } }) {
2567
+ id
2568
+ product_variant_prices(
2569
+ where: {
2570
+ price_type: { _eq: CLIENT }
2571
+ _or: [
2572
+ { chain_id: { _eq: $chainId } }
2573
+ { chain_id: { _is_null: true } }
2574
+ ]
2575
+ }
2576
+ ) {
2577
+ id
2578
+ price
2579
+ price_type
2580
+ chain_id
2581
+ }
2582
+ }
2524
2583
  }
2525
2584
  brands(
2526
2585
  where: {
@@ -3002,6 +3061,7 @@ function mapProduct(raw, storageUrl, labels, chainId) {
3002
3061
  createdAt: raw.created_at,
3003
3062
  updatedAt: raw.updated_at ?? raw.created_at,
3004
3063
  variants,
3064
+ outOfStockVisibilityOverride: raw.product_website_publications?.[0]?.show_when_out_of_stock ?? null,
3005
3065
  detailVariants,
3006
3066
  media: raw.product_media.map((m) => mapMedia(m, storageUrl)),
3007
3067
  attributes: raw.product_attributes.map(
@@ -3363,7 +3423,7 @@ async function getWebsiteAvailabilityByVariantId(graphqlUrl, getHeaders, variant
3363
3423
  }
3364
3424
  return availabilityByVariantId;
3365
3425
  }
3366
- async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
3426
+ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false, onlyInStock = false) {
3367
3427
  const variantIds = products.flatMap(
3368
3428
  (product) => product.variants.map((variant) => variant.id)
3369
3429
  );
@@ -3389,11 +3449,11 @@ async function filterProductsForWebsiteStock(graphqlUrl, getHeaders, products, c
3389
3449
  pricing: resolveProductPricing(prices)
3390
3450
  };
3391
3451
  }).filter(
3392
- (variant) => inStockVariantIds.has(variant.id) && variant.pricing.currentPrice != null
3452
+ (variant) => (inStockVariantIds.has(variant.id) || !onlyInStock && (product.outOfStockVisibilityOverride ?? showOutOfStockByDefault)) && variant.pricing.currentPrice != null
3393
3453
  )
3394
3454
  })).filter((product) => product.variants.length > 0);
3395
3455
  }
3396
- async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId) {
3456
+ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products, chainId, websiteId, showOutOfStockByDefault = false) {
3397
3457
  const variantIds = products.flatMap(
3398
3458
  (product) => product.product_variants.map((variant) => variant.id)
3399
3459
  );
@@ -3415,7 +3475,7 @@ async function filterSeoProductsForWebsiteStock(graphqlUrl, getHeaders, products
3415
3475
  const pricing = resolveProductPricing(
3416
3476
  selectPublicPrices(prices, chainId)
3417
3477
  );
3418
- return inStockVariantIds.has(variant.id) && pricing.currentPrice != null;
3478
+ return (inStockVariantIds.has(variant.id) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? showOutOfStockByDefault)) && pricing.currentPrice != null;
3419
3479
  })
3420
3480
  );
3421
3481
  }
@@ -3486,7 +3546,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
3486
3546
  getHeaders,
3487
3547
  [mappedProduct],
3488
3548
  ctx.chainId,
3489
- ctx.websiteId
3549
+ ctx.websiteId,
3550
+ ctx.config?.show_out_of_stock_products === true
3490
3551
  );
3491
3552
  if (!filteredProducts[0]) return null;
3492
3553
  const specifications = await loadProductSpecifications([product.id]);
@@ -3719,7 +3780,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
3719
3780
  getHeaders,
3720
3781
  data.products ?? [],
3721
3782
  ctx.chainId,
3722
- ctx.websiteId
3783
+ ctx.websiteId,
3784
+ ctx.config?.show_out_of_stock_products === true
3723
3785
  );
3724
3786
  const entries = availableProducts.slice(0, limit).map((product) => mapProductSeoEntry(product, storageUrl)).filter((entry) => Boolean(entry));
3725
3787
  return {
@@ -3796,7 +3858,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
3796
3858
  (p) => mapProduct(p, storageUrl, publicAttributeLabels, chainId)
3797
3859
  ),
3798
3860
  chainId,
3799
- ctx.websiteId
3861
+ ctx.websiteId,
3862
+ ctx.config?.show_out_of_stock_products === true,
3863
+ opts?.inStock === true
3800
3864
  );
3801
3865
  const specifications = await loadProductSpecifications(
3802
3866
  products.map((product) => product.id)
@@ -3903,6 +3967,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
3903
3967
  {
3904
3968
  companyId: ctx.companyId,
3905
3969
  chainId,
3970
+ websiteId: ctx.websiteId,
3906
3971
  attributeListKey: DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
3907
3972
  where: buildProductWhere(opts.filters ?? {}, chainId)
3908
3973
  },
@@ -3926,7 +3991,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
3926
3991
  variant.product_variant_prices.map(mapPrice),
3927
3992
  chainId
3928
3993
  );
3929
- return prices.length > 0 && (availabilityByVariantId.get(variant.id)?.inStock ?? false);
3994
+ return prices.length > 0 && ((availabilityByVariantId.get(variant.id)?.inStock ?? false) || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true));
3930
3995
  });
3931
3996
  if (!hasVisibleVariant) continue;
3932
3997
  applicableCategories.add(product.category);
@@ -4014,6 +4079,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4014
4079
  {
4015
4080
  companyId: ctx.companyId,
4016
4081
  chainId,
4082
+ websiteId: ctx.websiteId,
4017
4083
  attributeListKey: opts?.attributeListKey ?? DEFAULT_FILTER_ATTRIBUTE_LIST_KEY,
4018
4084
  where: {
4019
4085
  ...opts?.categoryName ? { category: { _eq: opts.categoryName } } : {},
@@ -4068,7 +4134,9 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4068
4134
  chainId
4069
4135
  ),
4070
4136
  inStock: availabilityByVariantId.get(variant.id)?.inStock ?? false
4071
- })).filter((variant) => variant.inStock && variant.prices.length > 0);
4137
+ })).filter(
4138
+ (variant) => (variant.inStock || (product.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true)) && variant.prices.length > 0
4139
+ );
4072
4140
  if (visibleVariants.length === 0) continue;
4073
4141
  categoryCounts.set(
4074
4142
  product.category,
@@ -4153,6 +4221,7 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4153
4221
  "NO_CHAIN"
4154
4222
  );
4155
4223
  }
4224
+ const chainId = ctx.chainId;
4156
4225
  const term = `%${opts.query}%`;
4157
4226
  const limit = opts.limit ?? 8;
4158
4227
  const data = await executeGraphQL(
@@ -4160,7 +4229,8 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4160
4229
  GET_SEARCH_SUGGESTIONS,
4161
4230
  {
4162
4231
  companyId: ctx.companyId,
4163
- chainId: ctx.chainId,
4232
+ chainId,
4233
+ websiteId: ctx.websiteId,
4164
4234
  term,
4165
4235
  productLimit: Math.min(limit, 5),
4166
4236
  brandLimit: Math.max(limit - 5, 3)
@@ -4168,8 +4238,29 @@ function createCatalogModule(graphqlUrl, getHeaders, getContext, storageUrl) {
4168
4238
  getHeaders
4169
4239
  );
4170
4240
  const suggestions = [];
4241
+ const availability = await getWebsiteAvailabilityByVariantId(
4242
+ graphqlUrl,
4243
+ getHeaders,
4244
+ (data.products ?? []).flatMap(
4245
+ (product) => product.product_variants.map((variant) => variant.id)
4246
+ ),
4247
+ chainId,
4248
+ ctx.websiteId
4249
+ );
4171
4250
  for (const p of data.products ?? []) {
4172
- suggestions.push({ type: "product", text: p.name, id: p.id });
4251
+ const showWithoutStock = p.product_website_publications?.[0]?.show_when_out_of_stock ?? ctx.config?.show_out_of_stock_products === true;
4252
+ const isVisible = p.product_variants.some((variant) => {
4253
+ const hasPrice = resolveProductPricing(
4254
+ selectPublicPrices(
4255
+ variant.product_variant_prices.map(mapPrice),
4256
+ chainId
4257
+ )
4258
+ ).currentPrice != null;
4259
+ return hasPrice && (showWithoutStock || availability.get(variant.id)?.inStock === true);
4260
+ });
4261
+ if (isVisible) {
4262
+ suggestions.push({ type: "product", text: p.name, id: p.id });
4263
+ }
4173
4264
  }
4174
4265
  for (const b of data.brands ?? []) {
4175
4266
  suggestions.push({ type: "brand", text: b.name, id: b.id });