fix(storefront): accurately reflect out-of-stock products based on stock quantity and stockStatus
Deploy Canina / deploy (push) Failing after 2m7s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 10s

This commit is contained in:
devops committed 2026-10-14 15:10:59 +00:00
1 parent 6c53126cb6
commit 075f00a4ed
5 files changed
+22 -7

No files matched your search

@@ -190,6 +190,7 @@ export class ProductService {
metaDescription: (inputData.metaDescription as string) || undefined,
canonicalUrl: (inputData.canonicalUrl as string) || undefined,
keywords: typeof inputData.keywords === 'string' ? inputData.keywords : undefined,
stock: typeof inputData.stock === 'number' ? inputData.stock : (inputData.stock !== undefined && inputData.stock !== null ? Number(inputData.stock) : undefined),
stockStatus: (inputData.stockStatus as 'IN_STOCK' | 'OUT_OF_STOCK' | 'PRE_ORDER' | 'DISCONTINUED') || 'IN_STOCK',
noIndex: Boolean(inputData.noIndex),
noFollow: Boolean(inputData.noFollow),
+13
View File
@@ -12,3 +12,16 @@ export function cn(...classes: (string | boolean | undefined)[]) {
return classes.filter(Boolean).join(" ");
}
export function isProductOutOfStock(product?: {
stock?: number;
stockStatus?: "IN_STOCK" | "OUT_OF_STOCK" | "PRE_ORDER" | "DISCONTINUED" | string;
packageSize?: number | string;
} | null): boolean {
if (!product) return false;
if (product.stockStatus === "OUT_OF_STOCK" || product.stockStatus === "DISCONTINUED") return true;
if (typeof product.stock === "number" && product.stock <= 0) return true;
if (product.stock !== undefined && product.stock !== null && Number(product.stock) <= 0) return true;
if (product.packageSize !== undefined && product.packageSize !== null && Number(product.packageSize) <= 0) return true;
return false;
}