Product

Description

The product variable provides details about the collection on a Product Detail (PDP) page. It includes the collection’s ID, title, handle, description, and main image. The collection object is only available on PDP pages; outside of a PDP context, it is null.

Properties of Product

PropertyTypeScopeDescriptionExample
product.idStringPDPUnique id of the product2837648235648
product.availableForSaleBooleanPDPIndicates if the product is available for purchase.true
product.descriptionStringPDPThe textual description of the product in ShopifyBeach Shirt
product.handleStringPDPUser-friendly slug used in Shopify product URL.beach-shirt
product.imagesString[]PDPArray of images for the Product[ "https://sample.vajro.com/image.jpg" ]
product.tagsString[]PDPArray of Shopify tags attached to the product.["beach","new","flash_sale"]
product.titleStringPDPName of the productBeach Shirt
product.urlStringPDPThe URL of the producthttps://www.vajro.com/products/shirt
product.vendorStringPDPName of the vendor or brand.Vajro
product.selectedVariantObjectPDPCurrently selected variant of the productJSON containing all the details of the variant
[ { id: 1234, title: "Black" } ]
product.sellingPlanIdStringPDPID of the selected selling plan (if using subscriptions).1234234342
product.optionsObject[]PDPArray of option definitions (e.g. size, color). Each entry has name and value.[ { name: "Color", value: "Black" } ]
product.metafieldsObject[]PDPCustom key‑value pairs defined on the product.[ { key: "material", : value: "Black" } ]

Properties of variants

PropertyTypeScopeDescriptionExample
product.variants.idStringPDPUnique ID of the product variant871625368253
product.variants.titleBooleanPDPGiven name of the product variantPalm Blue
product.variants.imageBooleanPDPArray of image URLs of the variant[ "https://sample.vajro.com/image.jpg " ]
product.variants.isAvailableBooleanPDPAvailability of the varianttrue
product.variants.priceFloatPDPThe actual price of the product variant10.99
product.variants.formattedPriceStringPDPThe formatted price of the product variant along with the symbol and currency code which was setup under app settings10.99 USD
product.variants.compareAtPriceFloatPDPPrice of the variant to display as markdown, which is higher than actual price13.99
product.variants.formattedCompareAtPriceStringPDPThe formatted compare at price of the product variant along with the symbol and currency code which was setup under app settings$ 13.99
product.variants.selectedOptionsObject[]PDPList of option name/value pairs selected for this variant.[ { name: "Color", value: "Black" } ]
product.variants.skuStringPDPStock Keeping Unit of the Product variant12344145
product.variants.sellingPlanAccocationsObjectPDPSelling plan allocations for the variant (if applicable).

Usage Example

const product_data = Superfans.variables.product;

if (product_data) {
  // Display basic product info
  console.log(`Product: ${product.title} — ${product.price}`);

  // Show options (e.g. color, size)
  product.options?.forEach((opt) => {
    console.log(`Option: ${opt.name} = ${opt.value}`);
  });

  // Access the selected variant
  const selected_variant = product.selectedVariant;
  if (selected_variant) {
    console.log(`Selected variant SKU: ${variant.sku}`);
    console.log(`Variant price: ${variant.price}`);
  }
} else {
  // The product object is only available on PDPs
  console.log("Not on a product page.");
}

Best Practices

  1. PDP only: The product variable is defined only on product detail pages; always check for null when using it elsewhere.
  2. Listen for variant changes: Use the Variant Change listener to update UI elements (price, images, inventory) when a user selects a different variant.
  3. Use selectedVariant for accuracy: Display price, availability and SKU based on product.selectedVariant rather than the first variant by default.
  4. Handle optional fields gracefully: Fields like compareAtPrice, tags, metafields and sellingPlanId may be absent; guard against undefined values.
  5. Read‑only data: Do not attempt to modify properties of the product or its variants; they reflect Shopify data and cannot be edited from the client side.

Caveats

  1. Scope limited to PDP: The product variable returns null on any page that is not a product detail page
  2. Incomplete or missing fields: Not all products have tags, compare‑at prices, metafields or images; always check for existence before using these fields.
  3. Variant data types: Variant properties such as title, image, price, and compareAtPrice are strings/floats, not Booleans, even though the original table lists them incorrectly. Adjust your code accordingly.
  4. Selected variant availability: The selectedVariant may be null until a user selects an option; handle this case when displaying variant‑dependent information.