@liquidcommerce/elements-sdk 2.6.0-beta.12 → 2.6.0-beta.121
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 +100 -2518
- package/dist/index.checkout.esm.js +20445 -0
- package/dist/index.esm.js +28574 -20597
- package/dist/ssr-stub.checkout.esm.js +17 -0
- package/dist/ssr-stub.esm.js +277 -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 +19 -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-cart-action.service.d.ts +38 -0
- package/dist/types/core/client/actions/client-checkout-action.service.d.ts +75 -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 +6 -74
- package/dist/types/core/client/client-config.service.d.ts +10 -5
- package/dist/types/core/debug-panel/debug-panel.styles.d.ts +1 -1
- package/dist/types/core/google-tag-manager.service.d.ts +10 -1
- 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 +45 -49
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +15 -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 +36 -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 +47 -2
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +9 -0
- package/dist/types/index.checkout.umd.d.ts +4 -0
- package/dist/types/index.d.ts +8 -3
- package/dist/types/interfaces/api/cart.interface.d.ts +12 -7
- package/dist/types/interfaces/api/checkout.interface.d.ts +271 -0
- package/dist/types/interfaces/api/index.d.ts +5 -0
- package/dist/types/interfaces/api/product-list.interface.d.ts +15 -6
- package/dist/types/interfaces/api/product.interface.d.ts +10 -4
- package/dist/types/interfaces/client.interface.d.ts +74 -0
- package/dist/types/interfaces/component.interface.d.ts +7 -0
- package/dist/types/interfaces/config.interface.d.ts +44 -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 +10 -1
- package/dist/types/modules/address/address.command.d.ts +2 -1
- package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/cart/cart.commands.d.ts +9 -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 +6 -0
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +95 -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 +5 -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 +22 -0
- package/dist/types/modules/checkout/components/checkout-express-checkout.component.d.ts +61 -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-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 +6 -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 -2
- package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +4 -2
- package/dist/types/modules/checkout/components/index.d.ts +4 -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/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 +22 -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 +6 -0
- package/dist/types/ssr/stub.d.ts +10 -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/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/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 +213 -0
- package/docs/v1/api/actions/address-actions.md +286 -0
- package/docs/v1/api/actions/cart-actions.md +364 -0
- package/docs/v1/api/actions/checkout-actions.md +586 -0
- package/docs/v1/api/actions/product-actions.md +204 -0
- package/docs/v1/api/client.md +664 -0
- package/docs/v1/api/configuration.md +583 -0
- package/docs/v1/api/injection-methods.md +331 -0
- package/docs/v1/api/typescript-types.md +501 -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 +288 -0
- package/docs/v1/guides/address-component.md +435 -0
- package/docs/v1/guides/best-practices.md +365 -0
- package/docs/v1/guides/cart-component.md +800 -0
- package/docs/v1/guides/checkout-component.md +817 -0
- package/docs/v1/guides/events.md +1004 -0
- package/docs/v1/guides/product-component.md +761 -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 +133 -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,501 @@
|
|
|
1
|
+
# TypeScript Types Reference
|
|
2
|
+
|
|
3
|
+
All public types are exported from the main package entry point. Import them using the `type` keyword for optimal tree-shaking.
|
|
4
|
+
|
|
5
|
+
## Importing Types
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Elements } from '@liquidcommerce/elements-sdk';
|
|
9
|
+
import type {
|
|
10
|
+
ILiquidCommerceElementsClient,
|
|
11
|
+
ILiquidCommerceElementsConfig,
|
|
12
|
+
IInjectProductElement,
|
|
13
|
+
IInjectedComponent
|
|
14
|
+
} from '@liquidcommerce/elements-sdk';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For the checkout-only build:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ElementsCheckout } from '@liquidcommerce/elements-sdk/checkout';
|
|
21
|
+
import type {
|
|
22
|
+
IElementsCheckoutClient,
|
|
23
|
+
IElementsCheckoutActions,
|
|
24
|
+
ILiquidCommerceElementsCheckoutClientConfig,
|
|
25
|
+
IInjectedComponent
|
|
26
|
+
} from '@liquidcommerce/elements-sdk/checkout';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Client Types
|
|
32
|
+
|
|
33
|
+
### ILiquidCommerceElementsClient
|
|
34
|
+
|
|
35
|
+
Main SDK client interface returned by `Elements()`.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface ILiquidCommerceElementsClient {
|
|
39
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
40
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
41
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
42
|
+
injectCheckoutElement(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
|
|
43
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
44
|
+
injectProductListSearch(params: IInjectProductListSearchParams): Promise<void>;
|
|
45
|
+
injectProductListFilters(params: IInjectProductListFiltersParams): Promise<void>;
|
|
46
|
+
ui: ILiquidCommerceElementsUIMethod;
|
|
47
|
+
actions: ILiquidCommerceElementsActions;
|
|
48
|
+
getInjectedComponents(): Map<string, IInjectedComponent>;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### ILiquidCommerceElementsBuilderClient
|
|
54
|
+
|
|
55
|
+
Builder-pattern client interface returned by `ElementsBuilder()`.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface ILiquidCommerceElementsBuilderClient {
|
|
59
|
+
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
60
|
+
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
61
|
+
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
62
|
+
updateCartComponent(configs: UpdateCartComponent): void;
|
|
63
|
+
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
64
|
+
updateProductListComponent(configs: UpdateProductListComponent): void;
|
|
65
|
+
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
66
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
67
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
68
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
69
|
+
injectCheckoutElement(params: IInjectCheckoutBuilderParams): Promise<IInjectedComponent | null>;
|
|
70
|
+
injectProductList(params: IInjectProductListParams): Promise<void>;
|
|
71
|
+
actions: ILiquidCommerceElementsActions;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### IElementsCheckoutClient
|
|
77
|
+
|
|
78
|
+
Checkout-only client interface returned by `ElementsCheckout()`.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
interface IElementsCheckoutClient {
|
|
82
|
+
injectCheckout(params: IInjectCheckoutParams): Promise<IInjectedComponent | null>;
|
|
83
|
+
injectExpressCheckout(params: IInjectExpressCheckoutParams): Promise<IInjectedComponent | null>;
|
|
84
|
+
actions: { checkout: IElementsCheckoutActions };
|
|
85
|
+
destroy(): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface IInjectExpressCheckoutParams {
|
|
89
|
+
containerId: string;
|
|
90
|
+
checkoutId?: string; // omit to use the checkout already loaded
|
|
91
|
+
variant?: 'section' | 'buttons'; // 'buttons' is the default outside the checkout element
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Configuration Types
|
|
98
|
+
|
|
99
|
+
### ILiquidCommerceElementsConfig
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
interface ILiquidCommerceElementsConfig {
|
|
103
|
+
env?: ElementsEnv;
|
|
104
|
+
promoTicker?: IPromoTicker[];
|
|
105
|
+
customTheme?: IClientCustomThemeConfig;
|
|
106
|
+
debugMode?: DebugMode;
|
|
107
|
+
checkout?: ILiquidCommerceElementsCheckoutConfig;
|
|
108
|
+
proxy?: IElementsProxyConfig;
|
|
109
|
+
gtm?: IElementsGTMConfig;
|
|
110
|
+
development?: ILiquidCommerceElementsDevelopmentConfig;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### ILiquidCommerceElementsBuilderConfig
|
|
115
|
+
|
|
116
|
+
Same shape as `ILiquidCommerceElementsConfig`, used by `ElementsBuilder()`.
|
|
117
|
+
|
|
118
|
+
### ILiquidCommerceElementsCheckoutClientConfig
|
|
119
|
+
|
|
120
|
+
Same shape as `ILiquidCommerceElementsConfig`, used for the checkout-only client.
|
|
121
|
+
|
|
122
|
+
### IClientCustomThemeConfig
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface IClientCustomThemeConfig {
|
|
126
|
+
global?: UpdateComponentGlobalConfigs;
|
|
127
|
+
product?: UpdateProductComponent;
|
|
128
|
+
address?: UpdateAddressComponent;
|
|
129
|
+
cart?: UpdateCartComponent;
|
|
130
|
+
checkout?: UpdateCheckoutComponent;
|
|
131
|
+
productList?: UpdateProductListComponent;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### IElementsProxyConfig
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
interface IElementsProxyConfig {
|
|
139
|
+
baseUrl: string;
|
|
140
|
+
headers?: Record<string, string>;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### IElementsGTMConfig
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
interface IElementsGTMConfig {
|
|
148
|
+
gatewayUrl?: string;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`gatewayUrl` is the Google tag gateway path your own GTM container is served from (see [Analytics → Google tag gateway](../reference/analytics.md#google-tag-gateway)).
|
|
153
|
+
|
|
154
|
+
### ILiquidCommerceElementsDevelopmentConfig
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
interface ILiquidCommerceElementsDevelopmentConfig {
|
|
158
|
+
customApiUrl?: string;
|
|
159
|
+
openShadowDom?: boolean;
|
|
160
|
+
mockMode?: boolean; // when true, sends an 'X-Liquid-Api-Mock-Mode' header to receive mock data
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### ILiquidCommerceElementsCheckoutConfig
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
interface ILiquidCommerceElementsCheckoutConfig {
|
|
168
|
+
pageUrl?: string;
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See [Configuration Reference](./configuration.md) for detailed property descriptions.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Injection Types
|
|
177
|
+
|
|
178
|
+
### IInjectProductElement
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
interface IInjectProductElement {
|
|
182
|
+
containerId: string;
|
|
183
|
+
identifier: string;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### IInjectCheckoutParams
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
interface IInjectCheckoutParams {
|
|
191
|
+
containerId: string;
|
|
192
|
+
checkoutId?: string;
|
|
193
|
+
hideHeader?: boolean;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### IInjectCheckoutBuilderParams
|
|
198
|
+
|
|
199
|
+
`simulatePresale` and `presaleExpiresInMinutes` are builder-only preview controls (presale lock defaults to 15 minutes) and only take effect via `ElementsBuilder().injectCheckoutElement()`.
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
interface IInjectCheckoutBuilderParams extends IInjectCheckoutParams {
|
|
203
|
+
simulatePresale?: boolean;
|
|
204
|
+
presaleExpiresInMinutes?: number;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### IInjectProductListParams
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
interface IInjectProductListParams {
|
|
212
|
+
containerId: string;
|
|
213
|
+
slug: string;
|
|
214
|
+
rows?: number;
|
|
215
|
+
columns?: number;
|
|
216
|
+
filters?: ProductListFilterType[];
|
|
217
|
+
productUrl?: PLCProductUrl;
|
|
218
|
+
productOrder?: string[]; // display order, by UPC or grouping ID
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### PLCProductUrl
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
/**
|
|
226
|
+
* Product card link configuration.
|
|
227
|
+
*
|
|
228
|
+
* - String: template with `{upc}` (selected size's UPC) or `{grouping}`
|
|
229
|
+
* (product's salsifyGrouping ID). Replaced per product card.
|
|
230
|
+
* - Map: keyed by product identifier (UPC or salsifyGrouping ID — same
|
|
231
|
+
* identifier types accepted by `injectProductElement`). The card looks up
|
|
232
|
+
* UPC first, then grouping ID. Use this when partner PDPs have
|
|
233
|
+
* hand-curated URLs that aren't derivable from a single token.
|
|
234
|
+
*/
|
|
235
|
+
type PLCProductUrl = string | Record<string, string>;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### IInjectProductListSearchParams
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
interface IInjectProductListSearchParams {
|
|
242
|
+
containerId: string;
|
|
243
|
+
slug: string;
|
|
244
|
+
filters?: ProductListFilterType[];
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### IInjectProductListFiltersParams
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
interface IInjectProductListFiltersParams {
|
|
252
|
+
containerId: string;
|
|
253
|
+
slug: string;
|
|
254
|
+
filters?: ProductListFilterType[];
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### IBuilderInjectElementParams
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
interface IBuilderInjectElementParams {
|
|
262
|
+
type: ComponentType;
|
|
263
|
+
containerId: string;
|
|
264
|
+
[key: string]: any;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Component Types
|
|
271
|
+
|
|
272
|
+
### IInjectedComponent
|
|
273
|
+
|
|
274
|
+
Returned by all injection methods. Provides control over the injected component.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
interface IInjectedComponent {
|
|
278
|
+
getType(): ComponentType;
|
|
279
|
+
getElement(): HTMLElement;
|
|
280
|
+
rerender(): void;
|
|
281
|
+
destroy(): void;
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## UI Types
|
|
288
|
+
|
|
289
|
+
### ILiquidCommerceElementsUIMethod
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
interface ILiquidCommerceElementsUIMethod {
|
|
293
|
+
cartButton(containerId: string, showItemsCount?: boolean): void;
|
|
294
|
+
floatingCartButton(showItemsCount?: boolean): void;
|
|
295
|
+
cartSubtotal(elementId: string): void;
|
|
296
|
+
cartItemsCount(elementId: string, options?: { hideZero: boolean }): void;
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Action Types
|
|
303
|
+
|
|
304
|
+
### ILiquidCommerceElementsActions
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
interface ILiquidCommerceElementsActions {
|
|
308
|
+
product: IProductActions;
|
|
309
|
+
address: IAddressActions;
|
|
310
|
+
cart: ICartActions;
|
|
311
|
+
checkout: ICheckoutActions;
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### IElementsCheckoutActions
|
|
316
|
+
|
|
317
|
+
Checkout actions available in the checkout-only client. This is `ICheckoutActions` with `openCheckout`, `closeCheckout`, and `toggleCheckout` omitted -- the checkout-only client renders checkout independently and has no drawer navigation to open, close, or toggle.
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
interface IElementsCheckoutActions extends Omit<ICheckoutActions, 'openCheckout' | 'closeCheckout' | 'toggleCheckout'> {}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
See [Actions API](./actions/) for detailed method signatures.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Enum Types
|
|
328
|
+
|
|
329
|
+
### ElementsEnv
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
type ElementsEnv = 'staging' | 'production';
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### DebugMode
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
type DebugMode = 'none' | 'console' | 'panel';
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### FulfillmentType
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
type FulfillmentType = 'onDemand' | 'shipping';
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### ComponentType
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
type ComponentType =
|
|
351
|
+
| 'address' | 'product' | 'cart' | 'checkout'
|
|
352
|
+
| 'product-list' | 'product-list-card' | 'product-list-filters' | 'product-list-search'
|
|
353
|
+
| 'drawer' | 'input' | 'engraving-form' | 'engraving-view'
|
|
354
|
+
| 'buttons-cart-open' | 'powered-by' | 'lce-element'
|
|
355
|
+
| 'purchase-min-alert' | 'alert' | 'promo-code-ticker'
|
|
356
|
+
// ...and additional internal component types
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### DisplayModeType
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
type DisplayModeType = 'modal' | 'drawer';
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Theme Configuration Types
|
|
368
|
+
|
|
369
|
+
### UpdateComponentGlobalConfigs
|
|
370
|
+
|
|
371
|
+
`DeepPartial<IComponentGlobalConfigs>` -- all properties optional.
|
|
372
|
+
|
|
373
|
+
### UpdateProductComponent
|
|
374
|
+
|
|
375
|
+
`DeepPartial<IProductComponent>` -- all properties optional.
|
|
376
|
+
|
|
377
|
+
### UpdateCartComponent
|
|
378
|
+
|
|
379
|
+
`DeepPartial<ICartComponent>` -- all properties optional.
|
|
380
|
+
|
|
381
|
+
### UpdateCheckoutComponent
|
|
382
|
+
|
|
383
|
+
`DeepPartial<ICheckoutComponent>` -- all properties optional.
|
|
384
|
+
|
|
385
|
+
### UpdateAddressComponent
|
|
386
|
+
|
|
387
|
+
`DeepPartial<IAddressComponent>` -- all properties optional.
|
|
388
|
+
|
|
389
|
+
### UpdateProductListComponent
|
|
390
|
+
|
|
391
|
+
Special structure for updating product list configuration by slug:
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
interface UpdateProductListComponent {
|
|
395
|
+
theme?: { backgroundColor?: string };
|
|
396
|
+
layout?: {
|
|
397
|
+
lists?: Record<string, DeepPartial<IPLCList>>;
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
These `Update*Component` types are the arguments to the `ElementsBuilder()` client's `update*Component` methods; see [Client API](./client.md) for their behavior and usage.
|
|
403
|
+
|
|
404
|
+
See [Configuration Reference](./configuration.md) for detailed theme property descriptions.
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Promo Ticker Type
|
|
409
|
+
|
|
410
|
+
### IPromoTicker
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
interface IPromoTicker {
|
|
414
|
+
promoCode: string;
|
|
415
|
+
text: string[];
|
|
416
|
+
separator: string;
|
|
417
|
+
activeFrom: string; // ISO 8601 UTC
|
|
418
|
+
activeUntil: string; // ISO 8601 UTC
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## Utility Types
|
|
425
|
+
|
|
426
|
+
### DeepPartial
|
|
427
|
+
|
|
428
|
+
Used internally for theme update types. Makes all properties in `T` recursively optional.
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
type DeepPartial<T> = {
|
|
432
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
433
|
+
};
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## See Also
|
|
439
|
+
|
|
440
|
+
- [Client API](./client.md) - Client initialization and usage
|
|
441
|
+
- [Configuration Reference](./configuration.md) - Detailed config options
|
|
442
|
+
- [Injection Methods](./injection-methods.md) - Component injection API
|
|
443
|
+
|
|
444
|
+
### Preparing complete account delivery details
|
|
445
|
+
|
|
446
|
+
After `lce:actions.checkout_loaded`, call
|
|
447
|
+
`await elements.actions.checkout.updateCustomerInfo(fields, { saveIfValid: true })`
|
|
448
|
+
to validate and prepare complete account details, then show their editable summary.
|
|
449
|
+
Supply names, email, a US phone number, and a real `birthDate` in `MM/DD/YYYY` format
|
|
450
|
+
(age 21+, year 1930 or later). The `birthDate` may be blank when the partner does not require a
|
|
451
|
+
date of birth (`checkout.layout.requireBirthDate: false`); a supplied one is still validated.
|
|
452
|
+
A shipping street must already be selected.
|
|
453
|
+
Omitted apartment and delivery instructions retain their existing checkout values.
|
|
454
|
+
Partial or invalid details stay in the form; backend validation failures reject the
|
|
455
|
+
promise, show the checkout error, and keep details editable. The host should handle that rejection.
|
|
456
|
+
|
|
457
|
+
The option skips gifts, saved forms, in-flight saves, and customer forms the shopper
|
|
458
|
+
has edited during the current checkout. It does not overwrite those forms. Edits or
|
|
459
|
+
address/checkout changes during preparation prevent a stale response from closing
|
|
460
|
+
the form. Without the option, this action only prefills fields, as before.
|
|
461
|
+
|
|
462
|
+
Apple Pay and Google Pay selection displays **Continue with Apple Pay** or
|
|
463
|
+
**Continue with Google Pay**. This opens the wallet to save a payment method; the
|
|
464
|
+
shopper still reviews and places the order afterward. It is not express checkout.
|
|
465
|
+
|
|
466
|
+
After wallet cancellation, the same Continue action remains available. If authorization
|
|
467
|
+
succeeded but saving the method failed, **Retry saving Apple Pay/Google Pay** reuses
|
|
468
|
+
the existing authorization rather than opening the wallet again.
|
|
469
|
+
|
|
470
|
+
### Saved account marketing preferences
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
setSavedMarketingPreferences(preferences: { canEmail?: boolean; canSms?: boolean }): Promise<void>
|
|
474
|
+
clearSavedMarketingPreferences(): void
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Call `actions.checkout.setSavedMarketingPreferences()` with known recorded account
|
|
478
|
+
choices, including `false`, before checkout loads. Only boolean values are used;
|
|
479
|
+
missing/null/unrecognized values remain unknown. The first checkout prepare uses
|
|
480
|
+
saved values instead of tenant defaults. Each channel's prompt is hidden only
|
|
481
|
+
after the server confirms that saved choice. Unknown channels retain their normal
|
|
482
|
+
checkout prompts. The actions are available in both full and checkout-only clients.
|
|
483
|
+
|
|
484
|
+
Calling the setter during an active checkout prepares untouched channels and
|
|
485
|
+
preserves shopper checkbox edits. Backend failure rejects the promise, displays
|
|
486
|
+
an error, and leaves prompts available; the host should catch the rejection.
|
|
487
|
+
The same call can retry. Applying values does not call a subscription service.
|
|
488
|
+
It supplies the account's recorded choices to this checkout.
|
|
489
|
+
|
|
490
|
+
Saved choices persist across cart resets in the same SDK session. Call
|
|
491
|
+
`clearSavedMarketingPreferences()` on sign-out, account change, and host cleanup.
|
|
492
|
+
Clearing reveals the prompts and restores configured guest defaults. It invalidates
|
|
493
|
+
stale responses while draining outstanding preference requests; checkout completion
|
|
494
|
+
prepares the current choices before submitting the checkout token. A load already
|
|
495
|
+
in progress still finishes and reconciles the current account's values. Bind a new
|
|
496
|
+
account only to its own checkout; the host remains responsible for account/cart
|
|
497
|
+
ownership and for reloading checkout when identity changes.
|
|
498
|
+
|
|
499
|
+
Order completion waits for queued preference work. It cannot race a late saved
|
|
500
|
+
opt-out or proceed with an unconfirmed saved choice. If applying a known choice
|
|
501
|
+
fails, the shopper can retry or explicitly choose the visible channel preference.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# UI Helpers API
|
|
2
|
+
|
|
3
|
+
UI helper methods for creating cart buttons and displaying cart information.
|
|
4
|
+
|
|
5
|
+
## ui.cartButton()
|
|
6
|
+
|
|
7
|
+
Create a cart button in a specific container.
|
|
8
|
+
|
|
9
|
+
### Signature
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
cartButton(containerId: string, showItemsCount?: boolean): void
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Required | Description |
|
|
18
|
+
|-----------|------|----------|-------------|
|
|
19
|
+
| `containerId` | string | Yes | ID of container element |
|
|
20
|
+
| `showItemsCount` | boolean | No | Show item count badge (default: false) |
|
|
21
|
+
|
|
22
|
+
### Example
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
// Simple cart button
|
|
26
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart');
|
|
27
|
+
|
|
28
|
+
// Cart button with item count badge
|
|
29
|
+
window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## ui.floatingCartButton()
|
|
35
|
+
|
|
36
|
+
Create a floating cart button (bottom-right corner).
|
|
37
|
+
|
|
38
|
+
### Signature
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
floatingCartButton(showItemsCount?: boolean): void
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Type | Required | Description |
|
|
47
|
+
|-----------|------|----------|-------------|
|
|
48
|
+
| `showItemsCount` | boolean | No | Show item count badge (default: false) |
|
|
49
|
+
|
|
50
|
+
### Example
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// Floating button without badge
|
|
54
|
+
window.LiquidCommerce.elements.ui.floatingCartButton();
|
|
55
|
+
|
|
56
|
+
// Floating button with badge
|
|
57
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ui.cartSubtotal()
|
|
63
|
+
|
|
64
|
+
Display cart subtotal in an element.
|
|
65
|
+
|
|
66
|
+
### Signature
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
cartSubtotal(elementId: string): void
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Parameters
|
|
73
|
+
|
|
74
|
+
| Parameter | Type | Required | Description |
|
|
75
|
+
|-----------|------|----------|-------------|
|
|
76
|
+
| `elementId` | string | Yes | ID of element to update |
|
|
77
|
+
|
|
78
|
+
### Example
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<div>Total: <span id="cart-total"></span></div>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
|
|
86
|
+
// Element now shows: "$49.99"
|
|
87
|
+
// Updates automatically when cart changes
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ui.cartItemsCount()
|
|
93
|
+
|
|
94
|
+
Display number of items in cart.
|
|
95
|
+
|
|
96
|
+
### Signature
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
cartItemsCount(elementId: string, options?: { hideZero: boolean }): void
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Parameters
|
|
103
|
+
|
|
104
|
+
| Parameter | Type | Required | Description |
|
|
105
|
+
|-----------|------|----------|-------------|
|
|
106
|
+
| `elementId` | string | Yes | ID of element to update |
|
|
107
|
+
| `options.hideZero` | boolean | No | Hide when cart is empty (default: true) |
|
|
108
|
+
|
|
109
|
+
### Example
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<div>Cart (<span id="items-count"></span>)</div>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Hide when cart is empty
|
|
117
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
118
|
+
|
|
119
|
+
// Always show count (even "0")
|
|
120
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', { hideZero: false });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Use Cases
|
|
124
|
+
|
|
125
|
+
### Header Cart Button
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<header>
|
|
129
|
+
<nav>
|
|
130
|
+
<a href="/">Home</a>
|
|
131
|
+
<a href="/products">Products</a>
|
|
132
|
+
<div id="cart-btn"></div>
|
|
133
|
+
</nav>
|
|
134
|
+
</header>
|
|
135
|
+
|
|
136
|
+
<script>
|
|
137
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
138
|
+
window.LiquidCommerce.elements.ui.cartButton('cart-btn', true);
|
|
139
|
+
}, { once: true });
|
|
140
|
+
</script>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Cart Summary Widget
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<aside class="cart-summary">
|
|
147
|
+
<h3>Your Cart</h3>
|
|
148
|
+
<p>Items: <span id="item-count"></span></p>
|
|
149
|
+
<p>Total: <span id="cart-total"></span></p>
|
|
150
|
+
</aside>
|
|
151
|
+
|
|
152
|
+
<script>
|
|
153
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
154
|
+
window.LiquidCommerce.elements.ui.cartItemsCount('item-count');
|
|
155
|
+
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
|
|
156
|
+
}, { once: true });
|
|
157
|
+
</script>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Floating Cart for Mobile
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// Show floating button only on mobile
|
|
164
|
+
if (window.innerWidth < 768) {
|
|
165
|
+
window.LiquidCommerce.elements.ui.floatingCartButton(true);
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Styling
|
|
170
|
+
|
|
171
|
+
Cart buttons and UI elements can be styled with CSS:
|
|
172
|
+
|
|
173
|
+
```css
|
|
174
|
+
/* Cart button container */
|
|
175
|
+
.lce-cart-desktop-button-container {
|
|
176
|
+
/* Your styles */
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Cart items count */
|
|
180
|
+
.lce-cart-items-count {
|
|
181
|
+
font-weight: bold;
|
|
182
|
+
color: #007bff;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* When cart is empty */
|
|
186
|
+
.lce-cart-items-count.no-items {
|
|
187
|
+
opacity: 0.5;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Cart subtotal */
|
|
191
|
+
.lce-cart-subtotal {
|
|
192
|
+
font-size: 1.2em;
|
|
193
|
+
font-weight: bold;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## See Also
|
|
198
|
+
|
|
199
|
+
- [Cart Component Guide](../guides/cart-component.md)
|
|
200
|
+
- [Cart Actions](./actions/cart-actions.md)
|