From 30a080182c325079e97cd813326b240e43d016de Mon Sep 17 00:00:00 2001 From: "Abhushan A. Joshi" <49617450+abhu-A-J@users.noreply.github.com> Date: Mon, 22 May 2023 22:34:27 +0530 Subject: [PATCH] Adds a basic product JSON-LD schema on product details page. (#1016) --- app/product/[handle]/page.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/product/[handle]/page.tsx b/app/product/[handle]/page.tsx index 612cd0236f..69252efc27 100644 --- a/app/product/[handle]/page.tsx +++ b/app/product/[handle]/page.tsx @@ -58,8 +58,31 @@ export default async function ProductPage({ params }: { params: { handle: string if (!product) return notFound(); + const productJsonLd = { + '@context': 'https://schema.org', + '@type': 'Product', + name: product.title, + description: product.description, + image: product.featuredImage.url, + offers: { + '@type': 'AggregateOffer', + availability: product.availableForSale + ? 'https://schema.org/InStock' + : 'https://schema.org/OutOfStock', + priceCurrency: product.priceRange.minVariantPrice.currencyCode, + highPrice: product.priceRange.maxVariantPrice.amount, + lowPrice: product.priceRange.minVariantPrice.amount + } + }; + return (