Skip to main content
shoppy.products.get(idOrHandle)
Fetches a single product by handle or Shopify GID.

Parameters

ParamTypeRequiredDescription
idOrHandlestringYesProduct handle or GID

Supported formats

FormatExample
Handle'blue-shirt'
Shopify GID'gid://shopify/Product/8834792939738'

Returns

ShopifyProduct | null Returns null if product not found.

Examples

By handle

const product = await shoppy.products.get('classic-cotton-shirt')

if (product) {
    console.log(product.title)
    console.log(product.priceRange.minVariantPrice.amount)
}

By GID

const product = await shoppy.products.get(
    'gid://shopify/Product/8834792939738'
)

With field selection

const product = await shoppy.products
    .select(['title', 'handle', 'priceRange', 'variants', 'options'])
    .get('classic-cotton-shirt')

Access variants

const product = await shoppy.products
    .select(['title', 'variants'])
    .get('classic-cotton-shirt')

product?.variants.forEach((variant) => {
    console.log(variant.id)
    console.log(variant.title)
    console.log(variant.price.amount)
    console.log(variant.availableForSale)
})

Find specific variant

const product = await shoppy.products
    .select(['variants'])
    .get('classic-cotton-shirt')

const variant = product?.variants.find(
    (v) =>
        v.selectedOptions.some(
            (opt) => opt.name === 'Size' && opt.value === 'M'
        ) &&
        v.selectedOptions.some(
            (opt) => opt.name === 'Color' && opt.value === 'Blue'
        )
)

console.log(variant?.id) // Use for cart
console.log(variant?.price.amount)

Access options

const product = await shoppy.products
    .select(['options'])
    .get('classic-cotton-shirt')

product?.options.forEach((option) => {
    console.log(option.name) // "Size", "Color"
    console.log(option.values) // ["S", "M", "L"], ["Blue", "Red"]
})

Handle not found

const product = await shoppy.products.get('non-existent-product')

if (!product) {
    console.log('Product not found')
}