Get the store
init() starts
loading it in the background, so by the time your code asks, it’s usually already there.
Like every data call, it resolves rather than throws when something goes wrong - the only rejection is
when there’s no store to ask for, which Installation
covers. So check success before reading data:
The store object
null, so treat every optional field as
possibly missing. The complete list is on the TypeScript page.
Products
store.products holds public products, and also unlisted and on-hold ones:
Private products (
2) are never sent. For a product grid, keep the public ones, in the merchant’s
order:
Categories
store.products, so look each one up and skip what you don’t find:
Logo and banner
branding.accentColor is the merchant’s brand color. The script’s own built-in UI
uses it, and your storefront can too.
Policies and support
The merchant’s policy pages, when they’ve set them, belong in your footer:Maintenance mode
When the merchant puts the store into maintenance mode,maintenanceReason holds their message. Show
it in place of the shop:
Public statistics
success: true. When the merchant hasn’t turned statistics on - or they
can’t be loaded - the strings are empty and averageRating is null, so hide the section when
totalOrders is empty.
Caching
The store, the banner URL and the currency formatter are cached in memory for five minutes, so callinggetStore() from every component costs one request, not one each. Concurrent calls share the same
request too. The cache lasts as long as the page: a reload fetches fresh data.
getProduct() and getProductReviews() aren’t cached - each call is a request.
Next
Products
Variants, stock, subscriptions, volume pricing and reviews
Images
Turning image file names into URLs