@liquidcommerce/elements-sdk 2.6.0-beta.13 → 2.6.0-beta.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -2518
- package/dist/index.checkout.esm.js +22524 -0
- package/dist/index.esm.js +30689 -20632
- package/dist/ssr-stub.checkout.esm.js +17 -0
- package/dist/ssr-stub.esm.js +281 -0
- package/dist/types/auto-initialize/checkout.d.ts +2 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +51 -0
- package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +16 -2
- package/dist/types/clients/builder.d.ts +3 -0
- package/dist/types/clients/checkout.d.ts +6 -0
- package/dist/types/clients/helpers.d.ts +8 -0
- package/dist/types/clients/main.d.ts +3 -0
- package/dist/types/constants/core.constant.d.ts +13 -18
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/prop65.constant.d.ts +8 -0
- package/dist/types/core/a11y/announcer.service.d.ts +16 -0
- package/dist/types/core/a11y/focus-manager.service.d.ts +21 -0
- package/dist/types/core/a11y/focusable.d.ts +5 -0
- package/dist/types/core/a11y/glyph-button.d.ts +8 -0
- package/dist/types/core/a11y/index.d.ts +6 -0
- package/dist/types/core/a11y/required.d.ts +1 -0
- package/dist/types/core/a11y/single-select.d.ts +20 -0
- package/dist/types/core/api/api-client.service.d.ts +23 -18
- package/dist/types/core/api/api-result.d.ts +20 -0
- package/dist/types/core/api/auth-client.service.d.ts +37 -13
- package/dist/types/core/api/http-client.service.d.ts +0 -8
- package/dist/types/core/base-component.service.d.ts +4 -1
- package/dist/types/core/client/actions/base-action.service.d.ts +22 -0
- package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
- package/dist/types/core/client/actions/client-analytics-action.service.d.ts +35 -0
- package/dist/types/core/client/actions/client-cart-action.service.d.ts +38 -0
- package/dist/types/core/client/actions/client-checkout-action.service.d.ts +81 -0
- package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
- package/dist/types/core/client/client-action.service.d.ts +7 -74
- package/dist/types/core/client/client-config.service.d.ts +12 -5
- package/dist/types/core/debug-panel/debug-panel.styles.d.ts +1 -1
- package/dist/types/core/google-tag-manager.service.d.ts +13 -3
- package/dist/types/core/logger/logger.service.d.ts +1 -1
- package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
- package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +6 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +54 -48
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +18 -7
- package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
- package/dist/types/core/singleton-manager.service.d.ts +12 -8
- package/dist/types/core/store/interfaces/cart.interface.d.ts +2 -3
- package/dist/types/core/store/interfaces/checkout.interface.d.ts +40 -107
- package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
- package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
- package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
- package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
- package/dist/types/core/store/store.constant.d.ts +5 -0
- package/dist/types/core/store/store.service.d.ts +1 -0
- package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +51 -2
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +11 -0
- package/dist/types/index.checkout.umd.d.ts +4 -0
- package/dist/types/index.d.ts +9 -3
- package/dist/types/interfaces/analytics.interface.d.ts +41 -0
- package/dist/types/interfaces/api/cart.interface.d.ts +14 -7
- package/dist/types/interfaces/api/checkout.interface.d.ts +277 -0
- package/dist/types/interfaces/api/delivery.interface.d.ts +24 -0
- package/dist/types/interfaces/api/index.d.ts +6 -0
- package/dist/types/interfaces/api/product-list.interface.d.ts +15 -6
- package/dist/types/interfaces/api/product.interface.d.ts +12 -4
- package/dist/types/interfaces/client.interface.d.ts +79 -0
- package/dist/types/interfaces/component.interface.d.ts +7 -0
- package/dist/types/interfaces/config.interface.d.ts +45 -0
- package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/cart.interface.d.ts +2 -1
- package/dist/types/interfaces/configs/checkout.interface.d.ts +3 -1
- package/dist/types/interfaces/configs/global.interface.d.ts +9 -3
- package/dist/types/interfaces/configs/index.d.ts +1 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
- package/dist/types/interfaces/configs/product.interface.d.ts +7 -1
- package/dist/types/interfaces/injection.interface.d.ts +56 -0
- package/dist/types/modules/address/address-display.component.d.ts +3 -1
- package/dist/types/modules/address/address-input.component.d.ts +11 -1
- package/dist/types/modules/address/address.command.d.ts +3 -2
- package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/cart/cart.commands.d.ts +11 -5
- package/dist/types/modules/cart/components/cart-body.component.d.ts +1 -0
- package/dist/types/modules/cart/components/cart-fulfillment.component.d.ts +1 -1
- package/dist/types/modules/cart/components/cart-item-quantity-price.component.d.ts +5 -0
- package/dist/types/modules/cart/components/cart-item.component.d.ts +8 -0
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +134 -12
- package/dist/types/modules/checkout/checkout.component.d.ts +7 -1
- package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +5 -2
- package/dist/types/modules/checkout/components/checkout-buyer.component.d.ts +1 -0
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +9 -0
- package/dist/types/modules/checkout/components/checkout-deliver-to.component.d.ts +1 -0
- package/dist/types/modules/checkout/components/checkout-delivery-method.component.d.ts +24 -0
- package/dist/types/modules/checkout/components/checkout-delivery-scheduling.component.d.ts +53 -0
- package/dist/types/modules/checkout/components/checkout-express-checkout.component.d.ts +63 -0
- package/dist/types/modules/checkout/components/checkout-express-completion.component.d.ts +21 -0
- package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
- package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +4 -0
- package/dist/types/modules/checkout/components/checkout-item.component.d.ts +2 -0
- package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
- package/dist/types/modules/checkout/components/checkout-order-summary.component.d.ts +3 -0
- package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +9 -1
- package/dist/types/modules/checkout/components/checkout-place-order-button.component.d.ts +1 -5
- package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +15 -1
- package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
- package/dist/types/modules/checkout/components/checkout-prop65-warning.component.d.ts +8 -0
- package/dist/types/modules/checkout/components/checkout-send-as-gift.component.d.ts +3 -0
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +7 -3
- package/dist/types/modules/checkout/components/checkout-stripe-handler.component.d.ts +4 -0
- package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +4 -2
- package/dist/types/modules/checkout/components/index.d.ts +5 -0
- package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
- package/dist/types/modules/checkout/components/required-fields-legend.d.ts +1 -0
- package/dist/types/modules/checkout/constant.d.ts +15 -0
- package/dist/types/modules/checkout/customer-prefill.d.ts +5 -0
- package/dist/types/modules/checkout/express-wallet.d.ts +12 -0
- package/dist/types/modules/checkout/payment-session-error.d.ts +4 -0
- package/dist/types/modules/checkout/stripe-js.d.ts +2 -0
- package/dist/types/modules/checkout/styles/delivery-method.style.d.ts +1 -0
- package/dist/types/modules/checkout/styles/express-checkout.style.d.ts +1 -0
- package/dist/types/modules/checkout/styles/express-completion.style.d.ts +1 -0
- package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product/components/components.d.ts +26 -2
- package/dist/types/modules/product/components/index.d.ts +1 -0
- package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +8 -1
- package/dist/types/modules/product/components/product-delivery-estimate.component.d.ts +11 -0
- package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
- package/dist/types/modules/product/components/product-drawer.component.d.ts +6 -0
- package/dist/types/modules/product/components/product-image-carousel.component.d.ts +5 -0
- package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
- package/dist/types/modules/product/components/product-prop65-warning.d.ts +1 -0
- package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +6 -0
- package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +12 -2
- package/dist/types/modules/product/components/product-retailers-popup.component.d.ts +1 -0
- package/dist/types/modules/product/components/product-retailers.component.d.ts +1 -0
- package/dist/types/modules/product/product.commands.d.ts +5 -5
- package/dist/types/modules/product/product.component.d.ts +3 -0
- package/dist/types/modules/product/styles/prop65-warning.style.d.ts +1 -0
- package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +6 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
- package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
- package/dist/types/modules/product-list/components/card-components/product-fulfillment-text.d.ts +2 -0
- package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +14 -0
- package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +11 -0
- package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +14 -0
- package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
- package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-checkbox-filter.components.d.ts → filter-components/product-list-checkbox-filter.d.ts} +1 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
- package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +15 -0
- package/dist/types/modules/product-list/components/{product-list-filters-subcomponents/product-list-price-filter.components.d.ts → filter-components/product-list-price-filter.d.ts} +2 -1
- package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
- package/dist/types/modules/product-list/components/index.d.ts +6 -2
- package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
- package/dist/types/modules/product-list/components/product-list-card.component.d.ts +39 -31
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
- package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +58 -36
- package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +54 -0
- package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
- package/dist/types/modules/product-list/product-list-filter.registry.d.ts +42 -0
- package/dist/types/modules/product-list/product-list-filter.utils.d.ts +7 -0
- package/dist/types/modules/product-list/product-list-order.utils.d.ts +3 -0
- package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
- package/dist/types/modules/product-list/product-list.commands.d.ts +27 -7
- package/dist/types/modules/product-list/product-list.component.d.ts +23 -47
- package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
- package/dist/types/modules/product-list/product-list.interface.d.ts +17 -28
- package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
- package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
- package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
- package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
- package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
- package/dist/types/modules/ui-components/alert/alert.component.d.ts +10 -10
- package/dist/types/modules/ui-components/buttons/buttons-open-cart.component.d.ts +5 -0
- package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +15 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +9 -1
- package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +7 -1
- package/dist/types/modules/ui-components/input/index.d.ts +0 -1
- package/dist/types/modules/ui-components/input/input.component.d.ts +15 -2
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
- package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
- package/dist/types/modules/ui-components/ui.commands.d.ts +7 -1
- package/dist/types/ssr/stub.checkout.d.ts +8 -0
- package/dist/types/ssr/stub.d.ts +12 -0
- package/dist/types/static/icon/arrow-right.icon.d.ts +1 -1
- package/dist/types/static/icon/bag.icon.d.ts +1 -1
- package/dist/types/static/icon/check.icon.d.ts +2 -0
- package/dist/types/static/icon/checkbox.icon.d.ts +1 -1
- package/dist/types/static/icon/chevron-down.icon.d.ts +1 -1
- package/dist/types/static/icon/chevron-left.icon.d.ts +1 -1
- package/dist/types/static/icon/chevron-up.icon.d.ts +1 -1
- package/dist/types/static/icon/close.icon.d.ts +1 -1
- package/dist/types/static/icon/error-info.icon.d.ts +1 -1
- package/dist/types/static/icon/filter.icon.d.ts +1 -1
- package/dist/types/static/icon/icon.a11y.d.ts +1 -0
- package/dist/types/static/icon/icon.types.d.ts +1 -0
- package/dist/types/static/icon/index.d.ts +2 -0
- package/dist/types/static/icon/info.icon.d.ts +1 -1
- package/dist/types/static/icon/loading-spinner.icon.d.ts +1 -1
- package/dist/types/static/icon/search.icon.d.ts +1 -1
- package/dist/types/static/icon/success.icon.d.ts +1 -1
- package/dist/types/static/icon/trash.icon.d.ts +1 -1
- package/dist/types/static/icon/warning.icon.d.ts +1 -1
- package/dist/types/utils/delivery-scheduling.d.ts +72 -0
- package/dist/types/utils/dom-compat.d.ts +2 -0
- package/dist/types/utils/format.d.ts +9 -14
- package/dist/types/utils/image-bg-removal.d.ts +3 -0
- package/dist/types/utils/places-session-token.d.ts +1 -0
- package/dist/types/utils/product-selection.d.ts +16 -0
- package/dist/types/utils/product.d.ts +21 -0
- package/dist/types/utils/timezone.d.ts +6 -0
- package/docs/v1/README.md +214 -0
- package/docs/v1/api/actions/address-actions.md +290 -0
- package/docs/v1/api/actions/analytics-actions.md +326 -0
- package/docs/v1/api/actions/cart-actions.md +364 -0
- package/docs/v1/api/actions/checkout-actions.md +629 -0
- package/docs/v1/api/actions/product-actions.md +205 -0
- package/docs/v1/api/client.md +671 -0
- package/docs/v1/api/configuration.md +587 -0
- package/docs/v1/api/injection-methods.md +331 -0
- package/docs/v1/api/typescript-types.md +610 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +199 -0
- package/docs/v1/examples/checkout-flow.md +90 -0
- package/docs/v1/examples/custom-theming.md +76 -0
- package/docs/v1/examples/multi-product-page.md +90 -0
- package/docs/v1/examples/simple-product-page.md +89 -0
- package/docs/v1/getting-started/concepts.md +521 -0
- package/docs/v1/getting-started/installation.md +351 -0
- package/docs/v1/getting-started/quick-start.md +410 -0
- package/docs/v1/guides/accessibility.md +298 -0
- package/docs/v1/guides/address-component.md +441 -0
- package/docs/v1/guides/best-practices.md +365 -0
- package/docs/v1/guides/cart-component.md +802 -0
- package/docs/v1/guides/checkout-component.md +920 -0
- package/docs/v1/guides/events.md +1061 -0
- package/docs/v1/guides/product-component.md +767 -0
- package/docs/v1/guides/product-list-component.md +730 -0
- package/docs/v1/guides/theming.md +243 -0
- package/docs/v1/integration/angular.md +39 -0
- package/docs/v1/integration/laravel.md +41 -0
- package/docs/v1/integration/nextjs.md +69 -0
- package/docs/v1/integration/proxy-setup.md +106 -0
- package/docs/v1/integration/react.md +64 -0
- package/docs/v1/integration/vanilla-js.md +84 -0
- package/docs/v1/integration/vue.md +58 -0
- package/docs/v1/reference/analytics.md +176 -0
- package/docs/v1/reference/browser-support.md +47 -0
- package/docs/v1/reference/error-handling.md +83 -0
- package/docs/v1/reference/performance.md +52 -0
- package/docs/v1/reference/telemetry.md +85 -0
- package/docs/v1/reference/troubleshooting.md +135 -0
- package/package.json +75 -45
- package/dist/types/elements-builder-client.d.ts +0 -2
- package/dist/types/elements-client-helper.d.ts +0 -4
- package/dist/types/elements-client.d.ts +0 -2
- package/dist/types/enums/cloud.enum.d.ts +0 -97
- package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
- package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
- package/dist/types/interfaces/cloud/index.d.ts +0 -3
- package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
- package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
- package/dist/types/interfaces/core.interface.d.ts +0 -111
- package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
- package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
- package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
- package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
- package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
- package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
- package/dist/types/utils/helper.d.ts +0 -28
- package/docs/ACTIONS.md +0 -1300
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -853
- package/docs/DOCUMENTATION_INDEX.md +0 -311
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -592
- package/docs/TROUBLESHOOTING.md +0 -793
- package/umd/elements.js +0 -1
- /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
- /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
- /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
# Client API
|
|
2
|
+
|
|
3
|
+
The Elements client is the main interface for interacting with the SDK. It provides methods for injecting components, managing UI elements, and performing actions.
|
|
4
|
+
|
|
5
|
+
## Initialization
|
|
6
|
+
|
|
7
|
+
### Elements()
|
|
8
|
+
|
|
9
|
+
Initialize the full SDK client.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
function Elements(
|
|
13
|
+
apiKey: string,
|
|
14
|
+
config?: ILiquidCommerceElementsConfig
|
|
15
|
+
): Promise<ILiquidCommerceElementsClient | null>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Parameters:**
|
|
19
|
+
|
|
20
|
+
| Parameter | Type | Required | Description |
|
|
21
|
+
|-----------|-------------------------------|----------|-----------------------------|
|
|
22
|
+
| `apiKey` | string | Yes | Your LiquidCommerce API key |
|
|
23
|
+
| `config` | ILiquidCommerceElementsConfig | No | Configuration object |
|
|
24
|
+
|
|
25
|
+
**Returns:** Promise that resolves to the client instance, or `null` if initialization fails.
|
|
26
|
+
|
|
27
|
+
**Example:**
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
31
|
+
|
|
32
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
33
|
+
env: 'production',
|
|
34
|
+
debugMode: 'console',
|
|
35
|
+
customTheme: { /* theme config */ }
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### ElementsCheckout()
|
|
40
|
+
|
|
41
|
+
Initialize the checkout-only client (tree-shaken build).
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
function ElementsCheckout(
|
|
45
|
+
apiKey: string,
|
|
46
|
+
config?: ILiquidCommerceElementsCheckoutClientConfig
|
|
47
|
+
): Promise<IElementsCheckoutClient | null>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Parameters:**
|
|
51
|
+
|
|
52
|
+
| Parameter | Type | Required | Description |
|
|
53
|
+
|-----------|---------------------------------------------|----------|-----------------------------|
|
|
54
|
+
| `apiKey` | string | Yes | Your LiquidCommerce API key |
|
|
55
|
+
| `config` | ILiquidCommerceElementsCheckoutClientConfig | No | Checkout configuration |
|
|
56
|
+
|
|
57
|
+
**Example:**
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
61
|
+
|
|
62
|
+
const client = await ElementsCheckout('YOUR_API_KEY', {
|
|
63
|
+
env: 'production'
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The checkout-only client exposes `injectCheckout()`, `injectExpressCheckout()`, `actions.checkout`,
|
|
68
|
+
`actions.analytics` and `destroy()`. `actions.analytics` reports the steps your own UI renders —
|
|
69
|
+
product views, address, availability, starting checkout — to the same GTM stream the checkout
|
|
70
|
+
reports to; see [Analytics Actions](./actions/analytics-actions.md).
|
|
71
|
+
|
|
72
|
+
#### injectExpressCheckout()
|
|
73
|
+
|
|
74
|
+
Injects only the Apple Pay and Google Pay wallet buttons, anywhere on the page, without the rest of
|
|
75
|
+
the checkout UI. Confirming the wallet sheet places the order outright — the wallet's contact and
|
|
76
|
+
billing details are sent to the checkout, so the shopper never fills a checkout form.
|
|
77
|
+
|
|
78
|
+
Express checkout is off by default: pass `development.enableExpressCheckout: true` in the client config to show it. Without it this
|
|
79
|
+
method renders nothing and resolves to `null`.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
injectExpressCheckout(params: IInjectExpressCheckoutParams): Promise<IInjectedComponent | null>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Parameter | Type | Required | Description |
|
|
86
|
+
|-----------|------|----------|-------------|
|
|
87
|
+
| `containerId` | string | Yes | ID of an element that already exists in the DOM |
|
|
88
|
+
| `checkoutId` | string | No | Checkout token to bind the buttons to. Omit to use the checkout already loaded |
|
|
89
|
+
| `variant` | `'buttons' \| 'section'` | No | `'buttons'` (default) is the wallet row alone; `'section'` adds the "Express Checkout" heading and OR divider |
|
|
90
|
+
|
|
91
|
+
A checkout is prepared at injection time rather than when a button is tapped: Stripe gives the
|
|
92
|
+
wallet's click handler one second to open its sheet, which is not enough time to create a checkout
|
|
93
|
+
and a payment session. Without a `checkoutId` the checkout already in the store is reused, so the
|
|
94
|
+
buttons can be injected beside a checkout the page has already loaded; the checkout-only client has
|
|
95
|
+
no cart to fall back on, so it throws when there is no loaded checkout to attach to. Inject again
|
|
96
|
+
with a new token whenever the address or fulfillment changes — the amounts the sheet shows come from
|
|
97
|
+
the checkout the buttons were prepared against.
|
|
98
|
+
|
|
99
|
+
The buttons only render where the shopper's platform offers a wallet, and the block hides itself
|
|
100
|
+
entirely otherwise. Subscribe to `lce:actions.checkout_express_checkout_availability` to know which
|
|
101
|
+
state you are in. Both wallets require an HTTPS origin on a domain registered with Stripe, each
|
|
102
|
+
subdomain separately — see the
|
|
103
|
+
[checkout component guide](../guides/checkout-component.md#express-checkout-apple-pay-and-google-pay).
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
await client.injectExpressCheckout({
|
|
107
|
+
containerId: 'express-checkout-container'
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The full client exposes the same component as `injectExpressCheckoutElement()`, with the same
|
|
112
|
+
parameters. It differs in one way: with no `checkoutId` and no checkout loaded, it prepares one from
|
|
113
|
+
the current cart rather than throwing.
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
await client.injectExpressCheckoutElement({
|
|
117
|
+
containerId: 'pdp-express-checkout'
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### ElementsBuilder()
|
|
122
|
+
|
|
123
|
+
Initialize the builder client, which exposes manual `inject*` / `update*` methods for fully programmatic composition.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
function ElementsBuilder(
|
|
127
|
+
apiKey: string,
|
|
128
|
+
config?: ILiquidCommerceElementsBuilderConfig
|
|
129
|
+
): Promise<ILiquidCommerceElementsBuilderClient | null>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Parameters:**
|
|
133
|
+
|
|
134
|
+
| Parameter | Type | Required | Description |
|
|
135
|
+
|-----------|--------------------------------------|----------|-----------------------------|
|
|
136
|
+
| `apiKey` | string | Yes | Your LiquidCommerce API key |
|
|
137
|
+
| `config` | ILiquidCommerceElementsBuilderConfig | No | Builder configuration object (same shape as `ILiquidCommerceElementsConfig`) |
|
|
138
|
+
|
|
139
|
+
**Returns:** Promise that resolves to the builder client instance (`ILiquidCommerceElementsBuilderClient`), or `null` if initialization fails or it is called outside the browser.
|
|
140
|
+
|
|
141
|
+
**Example:**
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
import { ElementsBuilder } from '@liquidcommerce/elements-sdk';
|
|
145
|
+
|
|
146
|
+
const builder = await ElementsBuilder('YOUR_API_KEY', {
|
|
147
|
+
env: 'production'
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Configuration
|
|
152
|
+
|
|
153
|
+
### ILiquidCommerceElementsConfig
|
|
154
|
+
|
|
155
|
+
Complete configuration interface for the full SDK.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
interface ILiquidCommerceElementsConfig {
|
|
159
|
+
// Optional
|
|
160
|
+
env?: ElementsEnv; // defaults to 'production' ('staging' | 'production')
|
|
161
|
+
debugMode?: DebugMode; // 'none' | 'console' | 'panel'
|
|
162
|
+
customTheme?: IClientCustomThemeConfig;
|
|
163
|
+
promoTicker?: IPromoTicker[];
|
|
164
|
+
proxy?: IElementsProxyConfig;
|
|
165
|
+
gtm?: IElementsGTMConfig;
|
|
166
|
+
checkout?: ILiquidCommerceElementsCheckoutConfig;
|
|
167
|
+
development?: ILiquidCommerceElementsDevelopmentConfig;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Environment
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
type ElementsEnv = 'staging' | 'production';
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Determines which API environment to use.
|
|
178
|
+
|
|
179
|
+
#### Debug Mode
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
type DebugMode = 'none' | 'console' | 'panel';
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- `'none'`: No debug output (production default)
|
|
186
|
+
- `'console'`: Log debug info to browser console
|
|
187
|
+
- `'panel'`: Show debug panel on page
|
|
188
|
+
|
|
189
|
+
#### Custom Theme
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
interface IClientCustomThemeConfig {
|
|
193
|
+
global?: UpdateComponentGlobalConfigs;
|
|
194
|
+
product?: UpdateProductComponent;
|
|
195
|
+
address?: UpdateAddressComponent;
|
|
196
|
+
cart?: UpdateCartComponent;
|
|
197
|
+
checkout?: UpdateCheckoutComponent;
|
|
198
|
+
productList?: UpdateProductListComponent;
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
See [Configuration Reference](./configuration.md) for detailed theme options.
|
|
203
|
+
|
|
204
|
+
#### Promo Ticker
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
interface IPromoTicker {
|
|
208
|
+
promoCode: string;
|
|
209
|
+
text: string[];
|
|
210
|
+
separator: string;
|
|
211
|
+
activeFrom: string; // ISO 8601 UTC format
|
|
212
|
+
activeUntil: string; // ISO 8601 UTC format
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Example:**
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
promoTicker: [{
|
|
220
|
+
promoCode: 'SUMMER20',
|
|
221
|
+
text: ['20% Off Summer Sale', 'Free Shipping on $50+'],
|
|
222
|
+
separator: '•',
|
|
223
|
+
activeFrom: '2026-06-01T00:00:00Z',
|
|
224
|
+
activeUntil: '2026-08-31T23:59:59Z'
|
|
225
|
+
}]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Proxy Configuration
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
interface IElementsProxyConfig {
|
|
232
|
+
baseUrl: string;
|
|
233
|
+
headers?: Record<string, string>;
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Example:**
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
proxy: {
|
|
241
|
+
baseUrl: 'https://yoursite.com/api/elements-proxy',
|
|
242
|
+
headers: {
|
|
243
|
+
'X-Custom-Header': 'value'
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
See [Proxy Setup Guide](../integration/proxy-setup.md) for implementation.
|
|
249
|
+
|
|
250
|
+
#### GTM Configuration
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
interface IElementsGTMConfig {
|
|
254
|
+
gatewayUrl?: string;
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Example:**
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
gtm: {
|
|
262
|
+
gatewayUrl: 'https://www.yoursite.com/metrics/'
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Set this when your site serves its own GTM container through Google tag gateway. See [Analytics → Google tag gateway](../reference/analytics.md#google-tag-gateway).
|
|
267
|
+
|
|
268
|
+
#### Checkout Configuration
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
interface ILiquidCommerceElementsCheckoutConfig {
|
|
272
|
+
pageUrl?: string; // Optional. URL pattern with {token} placeholder
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Example:**
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
checkout: {
|
|
280
|
+
pageUrl: 'https://yoursite.com/checkout?lce_checkout={token}'
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### Development Configuration
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
interface ILiquidCommerceElementsDevelopmentConfig {
|
|
288
|
+
customApiUrl?: string;
|
|
289
|
+
openShadowDom?: boolean;
|
|
290
|
+
mockMode?: boolean; // enable mock data responses (sends 'X-Liquid-Api-Mock-Mode' header)
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Example:**
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
development: {
|
|
298
|
+
customApiUrl: 'http://localhost:3000/api',
|
|
299
|
+
openShadowDom: true // Use an OPEN (inspectable) Shadow DOM instead of the default closed mode; forced off in production
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Global Access
|
|
304
|
+
|
|
305
|
+
After initialization, each client is available globally under the `window.LiquidCommerce` namespace:
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
window.LiquidCommerce.elements // full client (from Elements())
|
|
309
|
+
window.LiquidCommerce.elementsBuilder // builder client (from ElementsBuilder())
|
|
310
|
+
window.LiquidCommerce.elementsCheckout // checkout-only client (from ElementsCheckout())
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
This allows access from anywhere in your application:
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
// From any script
|
|
317
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Client Ready Event
|
|
321
|
+
|
|
322
|
+
Listen for client initialization:
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
window.addEventListener('lce:actions.client_ready', ( event ) => {
|
|
326
|
+
const { isReady, version, timestamp } = event.detail.data;
|
|
327
|
+
|
|
328
|
+
console.log(`Elements SDK v${version} ready`);
|
|
329
|
+
|
|
330
|
+
// Safe to use client
|
|
331
|
+
window.LiquidCommerce.elements.injectProductElement([...]);
|
|
332
|
+
}, { once: true });
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Client Interface
|
|
336
|
+
|
|
337
|
+
### ILiquidCommerceElementsClient
|
|
338
|
+
|
|
339
|
+
The main client interface:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
interface ILiquidCommerceElementsClient {
|
|
343
|
+
// Injection methods
|
|
344
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
345
|
+
|
|
346
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
347
|
+
|
|
348
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
349
|
+
|
|
350
|
+
injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
|
|
351
|
+
|
|
352
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
353
|
+
|
|
354
|
+
injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
|
|
355
|
+
|
|
356
|
+
injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
|
|
357
|
+
|
|
358
|
+
// UI methods
|
|
359
|
+
ui: ILiquidCommerceElementsUIMethod;
|
|
360
|
+
|
|
361
|
+
// Actions
|
|
362
|
+
actions: ILiquidCommerceElementsActions;
|
|
363
|
+
|
|
364
|
+
// Component management
|
|
365
|
+
getInjectedComponents(): Map<string, IInjectedComponent>;
|
|
366
|
+
|
|
367
|
+
// Cleanup
|
|
368
|
+
destroy(): void;
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### ILiquidCommerceElementsBuilderClient
|
|
373
|
+
|
|
374
|
+
The builder client (returned by `ElementsBuilder()`) exposes the same `inject*` methods plus a set of `update*Component` methods for applying theme/layout changes at runtime:
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
interface ILiquidCommerceElementsBuilderClient {
|
|
378
|
+
// Runtime theme/layout updates (builder-only)
|
|
379
|
+
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
380
|
+
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
381
|
+
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
382
|
+
updateCartComponent(configs: UpdateCartComponent): void;
|
|
383
|
+
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
384
|
+
updateProductListComponent(configs: UpdateProductListComponent): void;
|
|
385
|
+
|
|
386
|
+
// Injection methods
|
|
387
|
+
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
388
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
389
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
390
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
391
|
+
injectCheckoutElement(params: IInjectCheckoutBuilderParams): Promise<IInjectedComponent | null>;
|
|
392
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
393
|
+
|
|
394
|
+
// Actions
|
|
395
|
+
actions: ILiquidCommerceElementsActions;
|
|
396
|
+
|
|
397
|
+
// Cleanup
|
|
398
|
+
destroy(): void;
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
#### Runtime theme updates (`update*Component`)
|
|
403
|
+
|
|
404
|
+
These methods are **builder-only** — they exist on the client returned by `ElementsBuilder()` and are **not** available on the full `Elements()` client. Each method applies theme changes to its scope and, when the passed `configs` include a non-empty `layout`, triggers targeted rerenders of only the components affected by those layout fields.
|
|
405
|
+
|
|
406
|
+
Return types are not uniform:
|
|
407
|
+
|
|
408
|
+
- `updateComponentGlobalConfigs()` and `updateProductComponent()` return `Promise<void>` (they may await product rerenders) — `await` them.
|
|
409
|
+
- `updateCartComponent()`, `updateCheckoutComponent()`, `updateAddressComponent()`, and `updateProductListComponent()` return `void` (synchronous).
|
|
410
|
+
|
|
411
|
+
```javascript
|
|
412
|
+
const builder = await ElementsBuilder('YOUR_API_KEY', { env: 'production' });
|
|
413
|
+
|
|
414
|
+
// Asynchronous — await these
|
|
415
|
+
await builder.updateComponentGlobalConfigs({
|
|
416
|
+
theme: { primaryColor: '#0a7d33', buttonCornerRadius: '8px' },
|
|
417
|
+
layout: { allowPromoCodes: true }
|
|
418
|
+
});
|
|
419
|
+
await builder.updateProductComponent({
|
|
420
|
+
theme: { backgroundColor: '#ffffff' },
|
|
421
|
+
layout: { addToCartButtonText: 'Add to bag' }
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Synchronous — no await needed
|
|
425
|
+
builder.updateCartComponent({ layout: { drawerHeaderText: 'Your bag' } });
|
|
426
|
+
builder.updateCheckoutComponent({ layout: { placeOrderButtonText: 'Pay now' } });
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
#### injectCheckoutElement (builder)
|
|
430
|
+
|
|
431
|
+
The builder's `injectCheckoutElement()` accepts `IInjectCheckoutBuilderParams`, which extends `IInjectCheckoutParams` with two **preview-only** fields:
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
interface IInjectCheckoutBuilderParams extends IInjectCheckoutParams {
|
|
435
|
+
simulatePresale?: boolean; // simulate a presale lock in builder mode
|
|
436
|
+
presaleExpiresInMinutes?: number; // minutes until the simulated lock expires (defaults to 15)
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
`simulatePresale` and `presaleExpiresInMinutes` only take effect in the builder preview and have no counterpart on the full `Elements()` client's `injectCheckoutElement()`.
|
|
441
|
+
|
|
442
|
+
```javascript
|
|
443
|
+
await builder.injectCheckoutElement({
|
|
444
|
+
containerId: 'checkout',
|
|
445
|
+
simulatePresale: true,
|
|
446
|
+
presaleExpiresInMinutes: 30
|
|
447
|
+
});
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## Methods Overview
|
|
451
|
+
|
|
452
|
+
### Injection Methods
|
|
453
|
+
|
|
454
|
+
- `injectProductElement()` - Inject product displays
|
|
455
|
+
- `injectAddressElement()` - Inject address input
|
|
456
|
+
- `injectCartElement()` - Inject cart (rarely needed)
|
|
457
|
+
- `injectCheckoutElement()` - Inject checkout
|
|
458
|
+
- `injectProductList()` - Inject product catalog
|
|
459
|
+
- `injectProductListSearch()` - Inject search box
|
|
460
|
+
- `injectProductListFilters()` - Inject filter panel
|
|
461
|
+
|
|
462
|
+
See [Injection Methods](./injection-methods.md) for details.
|
|
463
|
+
|
|
464
|
+
### UI Methods
|
|
465
|
+
|
|
466
|
+
- `ui.cartButton()` - Add cart button
|
|
467
|
+
- `ui.floatingCartButton()` - Add floating cart button
|
|
468
|
+
- `ui.cartSubtotal()` - Display cart subtotal
|
|
469
|
+
- `ui.cartItemsCount()` - Display item count
|
|
470
|
+
|
|
471
|
+
See [UI Helpers](./ui-helpers.md) for details.
|
|
472
|
+
|
|
473
|
+
### Actions
|
|
474
|
+
|
|
475
|
+
- `actions.product.*` - Product actions
|
|
476
|
+
- `actions.address.*` - Address actions
|
|
477
|
+
- `actions.cart.*` - Cart actions
|
|
478
|
+
- `actions.checkout.*` - Checkout actions
|
|
479
|
+
|
|
480
|
+
See [Actions](./actions/) for details.
|
|
481
|
+
|
|
482
|
+
### Component Management
|
|
483
|
+
|
|
484
|
+
```javascript
|
|
485
|
+
// Get all injected components
|
|
486
|
+
const components = client.getInjectedComponents();
|
|
487
|
+
|
|
488
|
+
// Get specific component
|
|
489
|
+
const productComponent = components.get('product-1');
|
|
490
|
+
|
|
491
|
+
// Component methods
|
|
492
|
+
productComponent.getType(); // 'product'
|
|
493
|
+
productComponent.getElement(); // <div id="product-1">...</div>
|
|
494
|
+
productComponent.rerender(); // Force rerender
|
|
495
|
+
productComponent.destroy(); // Remove from DOM and clean up
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### destroy()
|
|
499
|
+
|
|
500
|
+
Remove the client and all injected components, cleaning up event listeners and internal state.
|
|
501
|
+
|
|
502
|
+
```javascript
|
|
503
|
+
client.destroy();
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## Error Handling
|
|
507
|
+
|
|
508
|
+
### SDKError
|
|
509
|
+
|
|
510
|
+
All SDK errors use the custom `SDKError` class:
|
|
511
|
+
|
|
512
|
+
```typescript
|
|
513
|
+
class SDKError extends Error {
|
|
514
|
+
constructor(message: string, reThrow?: boolean);
|
|
515
|
+
|
|
516
|
+
name: 'SDKError';
|
|
517
|
+
isSdk: boolean;
|
|
518
|
+
reThrow: boolean;
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
### Catching Errors
|
|
522
|
+
|
|
523
|
+
```javascript
|
|
524
|
+
try {
|
|
525
|
+
await client.injectProductElement([
|
|
526
|
+
{ containerId: 'product', identifier: 'invalid_id' }
|
|
527
|
+
]);
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (error.name === 'SDKError') {
|
|
530
|
+
console.error('SDK Error:', error);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Error Isolation
|
|
536
|
+
|
|
537
|
+
The SDK catches and contains its own errors:
|
|
538
|
+
|
|
539
|
+
```javascript
|
|
540
|
+
// Even if SDK throws, your app continues
|
|
541
|
+
window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
|
|
542
|
+
|
|
543
|
+
// Your code still runs
|
|
544
|
+
console.log('App still working');
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
## TypeScript Support
|
|
548
|
+
|
|
549
|
+
### Importing Types
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
553
|
+
import type {
|
|
554
|
+
ILiquidCommerceElementsClient,
|
|
555
|
+
ILiquidCommerceElementsConfig,
|
|
556
|
+
IInjectProductElement,
|
|
557
|
+
IInjectedComponent
|
|
558
|
+
} from '@liquidcommerce/elements-sdk';
|
|
559
|
+
|
|
560
|
+
const config: ILiquidCommerceElementsConfig = {
|
|
561
|
+
env: 'production'
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
// Elements() resolves to `null` on failure, so the type is nullable.
|
|
565
|
+
const client: ILiquidCommerceElementsClient | null = await Elements('KEY', config);
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### Type Exports
|
|
569
|
+
|
|
570
|
+
All public interfaces are exported from the main package:
|
|
571
|
+
|
|
572
|
+
```typescript
|
|
573
|
+
import type {
|
|
574
|
+
// Client types
|
|
575
|
+
ILiquidCommerceElementsClient,
|
|
576
|
+
ILiquidCommerceElementsConfig,
|
|
577
|
+
|
|
578
|
+
// Injection types
|
|
579
|
+
IInjectProductElement,
|
|
580
|
+
IInjectCheckoutParams,
|
|
581
|
+
IInjectedComponent,
|
|
582
|
+
|
|
583
|
+
// Configuration types
|
|
584
|
+
IClientCustomThemeConfig,
|
|
585
|
+
IComponentGlobalConfigs,
|
|
586
|
+
IProductComponent,
|
|
587
|
+
ICartComponent,
|
|
588
|
+
ICheckoutComponent,
|
|
589
|
+
IAddressComponent,
|
|
590
|
+
|
|
591
|
+
// Enum types
|
|
592
|
+
ElementsEnv,
|
|
593
|
+
DebugMode,
|
|
594
|
+
FulfillmentType,
|
|
595
|
+
ComponentType
|
|
596
|
+
} from '@liquidcommerce/elements-sdk';
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Both package entries, including their Node/SSR stubs, export `DeliverySlot`, `DeliveryAvailability`, `CheckoutDeliveryScheduling` and `CheckoutDeliverySelection`. Both clients expose `actions.checkout.loadDeliverySlots(fulfillmentId)` and `actions.checkout.chooseDeliverySlot(fulfillmentId, slotId)`.
|
|
600
|
+
|
|
601
|
+
See [TypeScript Types](./typescript-types.md) for complete type reference.
|
|
602
|
+
|
|
603
|
+
## Best Practices
|
|
604
|
+
|
|
605
|
+
### Single Client Instance
|
|
606
|
+
|
|
607
|
+
Create one client instance and reuse it:
|
|
608
|
+
|
|
609
|
+
```javascript
|
|
610
|
+
// Good
|
|
611
|
+
const client = await Elements('KEY', { env: 'production' });
|
|
612
|
+
await client.injectProductElement([...]);
|
|
613
|
+
await client.injectCartElement('cart');
|
|
614
|
+
|
|
615
|
+
// Bad - creates multiple instances
|
|
616
|
+
await Elements('KEY', { env: 'production' });
|
|
617
|
+
await Elements('KEY', { env: 'production' });
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Use Global Access
|
|
621
|
+
|
|
622
|
+
After initialization, use `window.LiquidCommerce.elements`:
|
|
623
|
+
|
|
624
|
+
```javascript
|
|
625
|
+
// Initialize once
|
|
626
|
+
await Elements('KEY', { env: 'production' });
|
|
627
|
+
|
|
628
|
+
// Use globally
|
|
629
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
630
|
+
window.LiquidCommerce.elements.ui.cartButton('cart-btn');
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### Check Client Ready
|
|
634
|
+
|
|
635
|
+
Wait for client ready before using:
|
|
636
|
+
|
|
637
|
+
```javascript
|
|
638
|
+
if (window.LiquidCommerce?.elements) {
|
|
639
|
+
// Client is ready
|
|
640
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
641
|
+
} else {
|
|
642
|
+
// Wait for client ready
|
|
643
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
644
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
645
|
+
}, { once: true });
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
### Handle Initialization Failures
|
|
650
|
+
|
|
651
|
+
```javascript
|
|
652
|
+
const client = await Elements('KEY', { env: 'production' });
|
|
653
|
+
|
|
654
|
+
if (!client) {
|
|
655
|
+
console.error('Failed to initialize Elements SDK');
|
|
656
|
+
// Show fallback UI or error message
|
|
657
|
+
showErrorPage();
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Client initialized successfully
|
|
662
|
+
await client.injectProductElement([...]);
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
## See Also
|
|
666
|
+
|
|
667
|
+
- [Injection Methods](./injection-methods.md) - Component injection API
|
|
668
|
+
- [UI Helpers](./ui-helpers.md) - UI helper methods
|
|
669
|
+
- [Actions](./actions/) - Action APIs
|
|
670
|
+
- [Configuration](./configuration.md) - Configuration options
|
|
671
|
+
- [TypeScript Types](./typescript-types.md) - Type definitions
|