API Reference
Utilities
The Shopify Addon provides various utility functions to help with integration and development.
getVersion
Returns the current version of the Shopify Addon.
Syntax
const version = ExtendShopify.getVersion()
Returns
| Type | Description |
|---|---|
string |
The current addon version |
Examples
// Get addon version
const version = ExtendShopify.getVersion()
console.log('Shopify Addon Version:', version)
// Version checking
if (version >= '1.14.0') {
console.log('Using latest features')
}
getBundleComponents
Retrieves component information for bundle products using Shopify’s Storefront GraphQL API.
Syntax
const components = await ExtendShopify.getBundleComponents(options)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
options |
GetBundleComponentsOptions | Yes | - | Configuration object |
Returns
| Type | Description |
|---|---|
| Promise<BundleComponentsData> | Promise resolving to bundle components data |
Examples
// Get bundle components for a variant
try {
const components = await ExtendShopify.getBundleComponents({
variantId: 'gid://shopify/ProductVariant/123456789'
})
if (components.requiresComponents) {
console.log('This variant requires component selection')
}
components.components.forEach(component => {
console.log(`Component: ${component.productVariant.title}`)
console.log(`Quantity: ${component.quantity}`)
console.log(`Price: ${component.productVariant.price.amount} ${component.productVariant.price.currencyCode}`)
console.log(`Product Type: ${component.productVariant.product.productType}`)
})
} catch (error) {
console.error('Failed to get components:', error)
}
// With custom store domain and fallback category
try {
const components = await ExtendShopify.getBundleComponents({
variantId: 'gid://shopify/ProductVariant/123456789',
storeDomain: 'my-store.myshopify.com',
fallbackCategory: 'Electronics'
})
console.log('Bundle components:', components)
} catch (error) {
console.error('Error:', error.message)
}
Type Definitions
BundleComponentsData
Result object containing bundle component information.
| Property | Type | Required | Description |
|---|---|---|---|
components |
BundleComponent[] | Yes | Array of bundle components |
requiresComponents |
boolean |
Yes | Whether this variant requires component selection |
BundleComponent
Individual component within a bundle product.
| Property | Type | Required | Description |
|---|---|---|---|
quantity |
number |
Yes | Quantity of this component in the bundle |
productVariant |
ProductVariant | Yes | Product variant information |
ProductVariant
Product variant information from Shopify GraphQL.
| Property | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Shopify variant ID |
title |
string |
No | Variant title |
price |
Price | Yes | Price information |
product |
ProductInfo | Yes | Parent product information |
Price
Price information for a product variant.
| Property | Type | Required | Description |
|---|---|---|---|
amount |
string |
Yes | Price amount as string |
currencyCode |
string |
Yes | Currency code (e.g., ‘USD’) |
ProductInfo
Basic product information from Shopify.
| Property | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Shopify product ID |
title |
string |
No | Product title |
productType |
string |
No | Product type/category |
GetBundleComponentsOptions
Configuration options for retrieving bundle components.
| Property | Type | Required | Description |
|---|---|---|---|
variantId |
string |
Yes | The Shopify variant ID (e.g., ‘gid://shopify/ProductVariant/123456789’) |
storeDomain |
string |
No | Store domain (defaults to window.Shopify.shop if available) |
fallbackCategory |
string |
No | Category to use when product variant has no productType (defaults to ‘General’) |