Skip to content
Kitenzo Headless is invite-only. To enable it on your store, email support@kitenzo.com.

@kitenzo/core

v0.4.0 · published

Framework-agnostic SDK. Zero runtime dependencies — it runs anywhere with fetch: browsers, Node, Workers, Deno, a TapCart block. Everything here is also re-exported by @kitenzo/react.

Terminal window
npm install @kitenzo/core

Default API base URL: https://live.bb.eight-cdn.com/api/headless/v1 (override with baseUrl).

These are the exact top-level value exports of @kitenzo/core (plus all TypeScript types):

ExportKindPurpose
KitenzoClientclassREST client for the headless API.
KitenzoErrorclassThrown on non-2xx responses (.status, .response).
createBundleBuilderfunctionFramework-agnostic builder state machine.
createBundleEmbedfunctionMount the full bundle UI (Mode 1).
addBundleToCartfunctionBuild + apply cart lines and _bundles.
buildCartPayloadfunctionReturn { lines, attributes } for a configured bundle.
buildCartLinesfunctionReturn just the cart lines.
toSellingPlanGidfunctionConvert a numeric selling plan id to its GID form.
createAjaxCartOperations / AjaxCartErrorfunction / classA ready-made CartOperations over Shopify’s AJAX cart (/cart/add.js), for widgets on a normal theme.
calculatePricefunctionLocal price calculation (flat + tiered).
calculatePriceWithConditionsfunctionLike calculatePrice, but applies a firing conditions-engine discount.
evaluateConditions / computeEffectivePricefunctionEvaluate the conditions-engine graph for a selection.
formatMoneyfunctionFormat a number with a Shopify money format string.
formatCurrencyfunctionFormat an amount for an arbitrary ISO currency (presentment prices).
resolvePresentmentPricingfunctionTurn a base-currency PriceResponse into the shopper’s market currency.
getSectionLimits / getBundleLimits / UNBOUNDEDfunction / constResolve limit rules into { min, max } pick windows.
defaultOptionValues / reachableOptionValues / resolveVariant / selectOptionValuefunctionOption-grid resolution — one dropdown per option instead of variant titles.
computeSectionQuantityfunctionTotal quantity selected in a section.
isSectionMetfunctionWhether a section meets its constraints.
createPortalClient / PortalApiError / SignedOutErrorfunction / classClient for agency-built Kitenzo Subscriptions customer portals (subscriptions beta).
new KitenzoClient({ apiKey, apiVersion?, baseUrl?, countryCode? })
MethodReturnsDescription
listBundles()Promise<Bundle[]>Published bundles (no product data).
getBundle(id, { countryCode? }?)Promise<BundleDetail>One bundle, with products/variants merged in. With a country, variants carry Shopify Markets presentment prices + market availability.
getPrice(bundle, selections, { countryCode? }?)Promise<PriceResponse>Server-authoritative pricing without creating a configuration. Base-currency amounts.
submitBundle(bundle, selections, { countryCode? }?)Promise<SubmitBundleResult>Validate + configure. Computes and forwards any conditions-engine discount automatically.
getSettings()Promise<ShopSettings>Shop currency, money format, weight unit, features.

A countryCode on the constructor is the default for getBundle / getPrice / submitBundle; the per-call option overrides it. Variant IDs accept GID or plain numeric strings. See Provider & client.

Returns a state machine with subscribe / getState (drives useSyncExternalStore in React, or vanilla DOM):

Methods: addItem(sectionId, variantId, quantity?), removeItem(sectionId, variantId), updateQuantity(sectionId, variantId, quantity), reset(), nextSection(), prevSection(), goToSection(index), getSectionQuantity(sectionId), getState(), subscribe(listener).

Snapshot (getState()): selections, currentSectionIndex, currentSection, isSectionValid, isValid, isComplete, isSatisfied, allItems, errors, conditions.

The React hook useBundleBuilder wraps this.

FunctionSignatureNotes
calculatePrice(bundle, selections, currency?) => PriceResponseFlat + tiered, all operations and operator modes. Local, no request.
calculatePriceWithConditions(bundle, selections, { currency?, currentStepName? }?) => PriceResponseApplies a firing conditional discount over calculatePrice. useBundlePrice uses it automatically.
formatMoney(amount, moneyFormat) => stringAll standard Shopify placeholders.
formatCurrency(amount, currencyCode) => stringFor presentment (market) amounts, where moneyFormat doesn’t apply.
resolvePresentmentPricing(bundle, selections, basePricing) => PriceResponse | nullMarket subtotal + the same discount ratio the base price used; null when no market data is loaded.
getSectionLimits / getBundleLimits(bundle, sectionId?) => PickLimits{ min, max } from the limit rules; open ceilings are UNBOUNDED. Don’t send through JSON.
defaultOptionValues / reachableOptionValues / resolveVariant / selectOptionValueOption-grid resolution; needs the API’s options + optionValues.
addBundleToCart / buildCartPayload / buildCartLinesSee Cart helpers.
createAjaxCartOperations(options?) => CartOperationsAJAX-cart transport for themed stores; turns non-2xx into real errors.
createBundleEmbed(container, options) => BundleEmbedInstanceSee Vanilla embed.
evaluateConditions(bundle, selections) => ConditionsEngineResultRaw conditions evaluation; the builder exposes the resolved result as snapshot.conditions.