summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-07-04 14:48:03 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-07-04 14:48:03 +0700
commit40b5e915d5675ed8d0e6f18860fb8f5e6a7ce59b (patch)
tree1f2138a18f9225f25a77e5ada3f6f7f5c4355adf /src/pages
parent024dbfafde6d337603743d08e76ba2d7fd1cfc63 (diff)
Update availability on google merchant xml
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/google_merchant/products/[page].js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 65e1ebbe..5a417807 100644
--- a/src/pages/google_merchant/products/[page].js
+++ b/src/pages/google_merchant/products/[page].js
@@ -34,6 +34,8 @@ export async function getServerSideProps({ res, query }) {
product.description = defaultProductDescription
}
+ const availability = product?.stockTotal > 0 ? 'in_stock' : 'preorder'
+
const item = {
'g:id': { '#text': productId },
'g:title': { '#text': toTitleCase(product.name) },
@@ -41,7 +43,7 @@ export async function getServerSideProps({ res, query }) {
'g:link': { '#text': productUrl },
'g:image_link': { '#text': product.image },
'g:condition': { '#text': 'new' },
- 'g:availability': { '#text': 'in_stock' },
+ 'g:availability': { '#text': availability },
'g:brand': { '#text': product.manufacture?.name || '' },
'g:price': { '#text': `${Math.floor(product.lowestPrice.price * 1.11)} IDR` }
}