feat(inventory): link online order reservations to database hold and sync numerical stock in RSS/Torob feeds
This commit is contained in:
1 parent
01de33ff2b
commit
d6a2136c70
3 files changed
+28
-8
No files matched your search
@@ -153,11 +153,14 @@ export async function GET(request: NextRequest) {
|
||||
: `${baseUrl}${proxied.startsWith('/') ? proxied : `/${proxied}`}`;
|
||||
}
|
||||
|
||||
const isInStock =
|
||||
product.stockStatus !== 'OUT_OF_STOCK' &&
|
||||
product.stockStatus !== 'out_of_stock' &&
|
||||
product.stockStatus !== 'DISCONTINUED' &&
|
||||
product.inStock !== false;
|
||||
const isOutOfStock =
|
||||
product.stockStatus === 'OUT_OF_STOCK' ||
|
||||
product.stockStatus === 'out_of_stock' ||
|
||||
product.stockStatus === 'DISCONTINUED' ||
|
||||
product.inStock === false ||
|
||||
(typeof product.stock === 'number' && product.stock <= 0);
|
||||
|
||||
const isInStock = !isOutOfStock;
|
||||
|
||||
const price = Number(product.priceValue || product.price || 0);
|
||||
const oldPrice = Number(product.oldPrice || product.priceValue || product.price || 0);
|
||||
|
||||
@@ -34,9 +34,17 @@ export async function GET() {
|
||||
imageLink = proxied.startsWith('http') ? proxied : `${baseUrl}${proxied.startsWith('/') ? proxied : `/${proxied}`}`;
|
||||
}
|
||||
|
||||
const isOutOfStock =
|
||||
product.stockStatus === 'OUT_OF_STOCK' ||
|
||||
product.stockStatus === 'DISCONTINUED' ||
|
||||
(typeof product.stock === 'number' && product.stock <= 0);
|
||||
|
||||
let availability = 'in_stock';
|
||||
if (product.stockStatus === 'OUT_OF_STOCK') availability = 'out_of_stock';
|
||||
if (product.stockStatus === 'PRE_ORDER') availability = 'preorder';
|
||||
if (isOutOfStock) {
|
||||
availability = 'out_of_stock';
|
||||
} else if (product.stockStatus === 'PRE_ORDER') {
|
||||
availability = 'preorder';
|
||||
}
|
||||
|
||||
const price = product.priceValue ? `${product.priceValue * 10} IRR` : '0 IRR';
|
||||
const gtinTag = product.barcode ? `<g:gtin>${product.barcode}</g:gtin>` : '';
|
||||
|
||||
Reference in new issue
Block a user