diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/google_merchant/products/[page].js | 7 | ||||
| -rw-r--r-- | src/pages/shop/product/variant/[slug].jsx | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index eeda4347..d6309090 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -47,6 +47,13 @@ export async function getServerSideProps({ res, query }) { 'g:brand': { '#text': product.manufacture?.name || '' }, 'g:price': { '#text': `${Math.round(product.lowestPrice.price * 1.11)} IDR` } } + + if (product.stockTotal == 0) { + item['g:custom_label_0'] = { '#text': 'Stok Tidak Tersedia' } + } else { + item['g:custom_label_1'] = { '#text': 'Stok Tersedia' } + } + if (product.lowestPrice.discountPercentage > 0) { item['g:sale_price'] = { '#text': `${Math.round(product.lowestPrice.priceDiscount * 1.11)} IDR` diff --git a/src/pages/shop/product/variant/[slug].jsx b/src/pages/shop/product/variant/[slug].jsx index ba2a79d5..88ac1c7f 100644 --- a/src/pages/shop/product/variant/[slug].jsx +++ b/src/pages/shop/product/variant/[slug].jsx @@ -6,6 +6,8 @@ import dynamic from 'next/dynamic' import { useRouter } from 'next/router' import cookie from 'cookie' import variantApi from '@/lib/product/api/variantApi' +import { useProductContext } from '@/contexts/ProductContext' +import { useEffect } from 'react' const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout')) const Product = dynamic(() => import('@/lib/product/components/Product/Product')) @@ -38,6 +40,14 @@ export async function getServerSideProps(context) { export default function ProductDetail({ product }) { const router = useRouter() + const { setProduct } = useProductContext() + + useEffect(() => { + if (product) { + setProduct(product) + } + }, [product, setProduct]) + if (!product) return <PageNotFound /> return ( |
