Skip to main content
This page lists every method and type in @shoppexio/storefront, grouped by object: Store, Products, Cart, Checkout, Reviews and invoices, and Types.
All async SDK methods return SDKResponse<T>, a wrapper containing data, error, and status fields. See Response types for the full definition.

Store

The Store object gives access to your shop’s public information, including name, branding, and settings.
For simple cases such as displaying the store logo, use getStoreLogoUrl() or getStoreBannerUrl(). They are lightweight wrappers that avoid fetching the full store metadata.

getStore

Fetches the store’s public metadata.
Response
Shop
Example: display store header

getStoreLogoUrl

Returns the store’s logo URL directly.
Response
string | null
Logo URL or null if no logo is set

getStoreBannerUrl

Returns the store’s banner URL directly.
Response
string | null
Banner URL or null if no banner is set

Store error handling

Products

Fetch products from your store, including variants, addons, and custom fields.

getProducts

Fetches all products from the store.
Response
Product[]
Array of products
Product prices are returned as string types to preserve decimal precision. Always use shoppex.formatPrice() for display. Do not calculate directly with price strings.
Use product images by surface:
  • cdn_image_url for product cards, category grids, cart rows, and search results
  • detail_image_url for product detail pages, image galleries, and zoom
  • images[] for the full gallery
Simple example: if your custom storefront currently renders the PDP hero from cdn_image_url, switch that hero to detail_image_url to get the higher-resolution image.
Example: product grid

getProduct

Fetches a single product by ID or slug.
Parameters
string
required
Product unique ID or URL slug
Example: product detail page

getCategories

Fetches all unique product category IDs from your store.
Example: category filter

Product groups

Stores can organize products into groups (for example, “Server Boosts”, “Tokens”). Groups come from getStorefront().
Breaking change in @shoppexio/storefront 1.0.0 (and the underlying storefront API): groups no longer embed full product objects in products_bound. Each group now carries product_uniqids, an array of product references, and every public product, standalone and group-bound, appears exactly once in the flat products list. If your integration reads group.products_bound, it sees undefined and must migrate to the lookup pattern below.
Group object
string
Unique group identifier
string
Group name
string[]
References to the group’s products. Resolve them against the flat products list. The full product objects are not embedded in the group.
number
Number of products in the group
number
Display order of the group
Resolving group products Build a lookup from the flat products list and resolve each group’s references.
If you install the SDK from npm, the same resolution is available as a named import.
Migrating from 0.3.x? Replace every group.products_bound read with the lookup above. getProducts() now returns the complete flat catalog, group-bound products included, so you no longer need to merge group products into your listing yourself. If you call the REST API directly, /v1/storefront/products/public/:slug groups carry product_uniqids. The /v1/storefront/products/shop/:name endpoint no longer returns groups at all. Read groups from the public catalog or bootstrap payload instead.

Working with variants

Products can have multiple variant types. Standard variants Variants such as size or color that do not change the price.
Price variants Variants that have different prices.
Addons Optional extras the customer can add.

Products error handling

Cart

The Cart object manages shopping cart state in the browser’s localStorage. Cart data stays saved across page refreshes and browser sessions.
Cart data is stored in the browser’s localStorage. If the user clears browser storage, the cart is lost.

getCart

Returns all items currently in the cart.
Response
CartItem[]

getCartItemCount

Returns the total number of items in the cart.

addToCart

Adds an item to the cart, or increments quantity if it already exists.
Parameters
string
required
Product unique identifier
string
required
Variant ID. Use empty string '' for products without variants.
number
default:"1"
Number of items to add
CartAddOptions
Example: add to cart button

updateCartItem

Updates an existing cart item.
Parameters
string
required
Product unique identifier
string
required
Variant ID
object
required

removeFromCart

Removes an item from the cart.
Parameters
string
required
Product unique identifier
string
required
Variant ID

clearCart

Removes all items from the cart.

Cart backup

The SDK can back up the cart before checkout, to restore it if checkout is cancelled. createCartBackup
restoreCartFromBackup

Complete cart UI example

Checkout

The Checkout object redirects customers to Shoppex hosted checkout. Checkout is fully hosted by Shoppex for PCI compliance.

checkout

Redirects the customer to the checkout page with their cart contents.
Parameters
string
Pre-applied coupon code
CheckoutOptions
Example: checkout with coupon

buildCheckoutUrl

Builds the checkout URL without redirecting. Use this to open checkout in a new tab or iframe.
Parameters
string
Coupon code to pre-apply
string
Checkout language (for example, ‘en’, ‘de’, ‘fr’)
Example: open checkout in new tab

buildCheckoutUrlSync (deprecated)

buildCheckoutUrlSync is deprecated and throws immediately. Use buildCheckoutUrl() instead. It handles both default and custom domains.

Coupons

validateCoupon Validates a coupon code before checkout. Affiliate and referral codes are separate from coupons. Use validateAffiliateCode or applyAffiliateCode for those instead.
Parameters
string
required
Coupon code to validate
string
Product ID to check product-specific coupons
string
Selected variant ID to check variant-specific coupons. Requires options.productId.
Response
CouponValidation

Affiliate codes

validateAffiliateCode Validates an affiliate or referral code without storing it.
applyAffiliateCode Validates and stores the normalized affiliate code. checkout() sends the stored code as affiliate_code.
Example: coupon input with validation

Checkout flow

After checkout

After successful checkout, the cart is automatically cleared. If you need to handle the return, read the order ID from the URL.

Reviews and invoices

This section documents two separate objects: shop reviews and invoice status.

getShopReviews

Fetches all public reviews for the store.
Response
Feedback[]
Example: reviews section

getInvoice

Fetches full invoice details.
Response
Invoice

getInvoiceStatus

Lightweight endpoint for status polling. Use this instead of getInvoice for real-time updates.
Example: order status page

Formatting utilities

formatPrice Formats a price with a currency symbol.
Parameters
number
required
Price amount
string
default:"Store currency"
ISO 4217 currency code
string
default:"en"
Locale for formatting
createFormatter Creates a reusable Intl.NumberFormat instance.

Types

The SDK is written in TypeScript and exports all type definitions. Install with npm to get full IntelliSense support.

Configuration types

Response types

Store types

Product types

Image fields have different jobs:
  • cdn_image_url is the optimized storefront cover for cards and lists
  • detail_image_url is the higher-resolution primary image for product detail pages
  • images[] contains the gallery
If you run a headless storefront, keep cards on cdn_image_url and switch your PDP hero and gallery to detail_image_url.

Cart types

Checkout types

Invoice types

Review types

Error types

Usage with TypeScript