Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

487 B
Raw Blame
/** "Product — Small / Blue", falling back to the SKU or the raw id. */
export function variantLabel(
  variant:
    | { product_name?: string | null; options_text?: string | null; sku?: string | null }
    | null
    | undefined,
  variantId: string | null | undefined,
): string {
  if (!variant) return variantId ?? ''

  const parts = [variant.product_name, variant.options_text].filter(Boolean)
  return parts.length > 0 ? parts.join(' — ') : (variant.sku ?? variantId ?? '')
}