@liquidcommerce/elements-sdk 2.6.0-beta.13 → 2.6.0-beta.130
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 +22267 -0
- package/dist/index.esm.js +30400 -20620
- 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 +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-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 +39 -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 +12 -7
- package/dist/types/interfaces/api/checkout.interface.d.ts +275 -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 +10 -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 +6 -0
- package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/checkout/checkout.commands.d.ts +128 -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 +7 -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-delivery-scheduling.component.d.ts +51 -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 +8 -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 +43 -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 +204 -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 +295 -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 +800 -0
- package/docs/v1/guides/checkout-component.md +916 -0
- package/docs/v1/guides/events.md +1061 -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 +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,629 @@
|
|
|
1
|
+
# Checkout Actions API
|
|
2
|
+
|
|
3
|
+
Checkout actions allow you to programmatically control the checkout flow.
|
|
4
|
+
|
|
5
|
+
## Navigation Actions
|
|
6
|
+
|
|
7
|
+
> **Note:** `openCheckout()`, `closeCheckout()`, and `toggleCheckout()` are only available on the full `Elements()` client's `actions.checkout`. They are **not** present on the checkout-only client (`ElementsCheckout()`), whose `actions.checkout` is typed `IElementsCheckoutActions = Omit<ICheckoutActions, 'openCheckout' | 'closeCheckout' | 'toggleCheckout'>`. The remaining checkout actions are available on both clients.
|
|
8
|
+
|
|
9
|
+
### actions.checkout.openCheckout()
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
openCheckout(): void
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Opens the checkout drawer or navigates to checkout page. Reports `begin_checkout` for the cart's items
|
|
16
|
+
to GTM, as the cart's own Checkout button does, unless the drawer already shows the checkout.
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
window.LiquidCommerce.elements.actions.checkout.openCheckout();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### actions.checkout.closeCheckout()
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
closeCheckout(): void
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Closes the checkout drawer.
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
window.LiquidCommerce.elements.actions.checkout.closeCheckout();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### actions.checkout.toggleCheckout()
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
toggleCheckout(): void
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Toggles checkout open/closed. Opening it reports `begin_checkout`, as `openCheckout()` does.
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
window.LiquidCommerce.elements.actions.checkout.toggleCheckout();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### actions.checkout.exitCheckout()
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
exitCheckout(): void
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Navigates away from checkout (requires `exitUrl` configuration).
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
window.LiquidCommerce.elements.actions.checkout.exitCheckout();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Product Actions
|
|
59
|
+
|
|
60
|
+
### actions.checkout.addProduct()
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Add products and open checkout in one call. Products are added to the cart (via the cart action, or directly when none is wired up), then checkout is prepared and opened. For a checkout without a cart session, use `addAnonymousProduct`.
|
|
67
|
+
|
|
68
|
+
Reports `add_to_cart` for the added products and then `begin_checkout` for the cart to GTM, so don't report either again with [`actions.analytics`](./analytics-actions.md).
|
|
69
|
+
|
|
70
|
+
`IAddProductParams.engravingLines?: string[]` — optional engraving. Same rules as [`actions.cart.addProduct()`](./cart-actions.md#actionscartaddproduct): invalid input is ignored, blanks stripped, lines clamped to the product's `maxLines` / `maxCharsPerLine`, and engraving is dropped (without failing) when the product, variant, or fulfillment doesn't support it.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
74
|
+
{
|
|
75
|
+
identifier: '00619947000020',
|
|
76
|
+
fulfillmentType: 'shipping',
|
|
77
|
+
quantity: 1
|
|
78
|
+
}
|
|
79
|
+
], true); // Open checkout after adding
|
|
80
|
+
|
|
81
|
+
// With engraving
|
|
82
|
+
await window.LiquidCommerce.elements.actions.checkout.addProduct([
|
|
83
|
+
{
|
|
84
|
+
identifier: '00619947000020',
|
|
85
|
+
fulfillmentType: 'shipping',
|
|
86
|
+
quantity: 1,
|
|
87
|
+
engravingLines: ['For Dad']
|
|
88
|
+
}
|
|
89
|
+
], true);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### actions.checkout.addAnonymousProduct()
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
addAnonymousProduct(
|
|
96
|
+
params: IAnonymousCheckoutAddProductParams
|
|
97
|
+
): Promise<IAnonymousCheckoutAddProductResponse>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Add a product to checkout without requiring a cart session. Used for direct-to-checkout flows.
|
|
101
|
+
|
|
102
|
+
**Parameters** (`IAnonymousCheckoutAddProductParams`):
|
|
103
|
+
|
|
104
|
+
| Field | Type | Required | Description |
|
|
105
|
+
|-------|------|----------|-------------|
|
|
106
|
+
| `location` | `ILocation` | Yes | `{ address: IAddressAddress; coordinates: IAddressCoordinates }` |
|
|
107
|
+
| `items` | `IAnonymousCheckoutAddProductItem[]` | No | Products to add: `{ identifier, fulfillmentType, quantity }`. Provide `items` **or** `cartItems`. |
|
|
108
|
+
| `cartItems` | `ICartUpdateItem[]` | No | Pre-resolved cart line items: `{ id?, partNumber, quantity, fulfillmentId, engravingLines? }` (alternative to `items`). |
|
|
109
|
+
| `promoCode` | `string` | No | Promo code applied while creating the anonymous checkout. |
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const result = await window.LiquidCommerce.elements.actions.checkout
|
|
113
|
+
.addAnonymousProduct({
|
|
114
|
+
items: [
|
|
115
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
116
|
+
],
|
|
117
|
+
location: {
|
|
118
|
+
address: { one: '123 Main St', two: '', city: 'New York', state: 'NY', zip: '10001', country: 'US' },
|
|
119
|
+
coordinates: { latitude: 40.7128, longitude: -74.006 }
|
|
120
|
+
},
|
|
121
|
+
promoCode: 'WELCOME10' // optional
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Returns** (`IAnonymousCheckoutAddProductResponse`):
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
interface IAnonymousCheckoutAddProductResponse {
|
|
129
|
+
checkout: ICheckoutPrepare | null; // the prepared checkout (see below), or null on failure
|
|
130
|
+
unavailableItems: IAnonymousCheckoutUnavailableItem[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface IAnonymousCheckoutUnavailableItem {
|
|
134
|
+
identifier: string;
|
|
135
|
+
productName: string | null;
|
|
136
|
+
fulfillmentType: FulfillmentType; // 'shipping' | 'onDemand'
|
|
137
|
+
reason: 'product_not_available' | 'fulfillment_not_available';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface ICheckoutPrepare {
|
|
141
|
+
token: string;
|
|
142
|
+
cartId: string;
|
|
143
|
+
customer: ICheckoutCustomer;
|
|
144
|
+
isGift: boolean;
|
|
145
|
+
billingSameAsShipping: boolean;
|
|
146
|
+
payment?: string;
|
|
147
|
+
giftOptions: ICheckoutGiftRecipient;
|
|
148
|
+
marketingPreferences: ICheckoutMarketingPreferences;
|
|
149
|
+
shippingAddress: ICheckoutShippingAddress;
|
|
150
|
+
billingAddress: ICheckoutBilling;
|
|
151
|
+
promoCode: ICheckoutPromoCode | null;
|
|
152
|
+
amounts: ICheckoutAmounts;
|
|
153
|
+
giftCards: ICheckoutGiftCard[];
|
|
154
|
+
presale: ICheckoutPresale | null;
|
|
155
|
+
itemsQuantity: number;
|
|
156
|
+
items: Record<string /* cart item ID */, ICheckoutItem>;
|
|
157
|
+
retailers: Record<string /* retailer ID */, ICheckoutRetailer>;
|
|
158
|
+
events: ICheckoutEvent[];
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Promo & Gift Card Actions
|
|
163
|
+
|
|
164
|
+
### actions.checkout.applyPromoCode()
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
applyPromoCode(promoCode: string): Promise<void>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Apply a promo code during checkout.
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### actions.checkout.removePromoCode()
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
removePromoCode(): Promise<void>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Remove the active promo code.
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
await window.LiquidCommerce.elements.actions.checkout.removePromoCode();
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### actions.checkout.applyGiftCard()
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
applyGiftCard(code: string): Promise<void>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Apply a gift card.
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
await window.LiquidCommerce.elements.actions.checkout.applyGiftCard('GIFT-1234-5678-9012');
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### actions.checkout.removeGiftCard()
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
removeGiftCard(code: string): Promise<void>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Remove a gift card.
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
await window.LiquidCommerce.elements.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Toggle Actions
|
|
213
|
+
|
|
214
|
+
### actions.checkout.toggleIsGift()
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
toggleIsGift(active?: boolean): Promise<void>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Enable/disable gift mode.
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
// Enable
|
|
224
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(true);
|
|
225
|
+
|
|
226
|
+
// Disable
|
|
227
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(false);
|
|
228
|
+
|
|
229
|
+
// Toggle
|
|
230
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift();
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### actions.checkout.toggleBillingSameAsShipping()
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
toggleBillingSameAsShipping(active?: boolean): Promise<void>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Set whether billing address matches shipping.
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
// Use shipping address for billing
|
|
243
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(true);
|
|
244
|
+
|
|
245
|
+
// Use different billing address
|
|
246
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### actions.checkout.toggleMarketingPreferences()
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
toggleMarketingPreferences(field: 'canEmail' | 'canSms', active: boolean): Promise<void>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Set marketing opt-in preferences.
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
// Opt into email marketing
|
|
259
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
260
|
+
|
|
261
|
+
// Opt into SMS marketing
|
|
262
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canSms', true);
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Form Update Actions
|
|
266
|
+
|
|
267
|
+
### actions.checkout.updateCustomerInfo()
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
updateCustomerInfo(params: Record<CustomerFieldName, string>, options?: { saveIfValid?: boolean }): Promise<void>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Pre-fill customer information.
|
|
274
|
+
|
|
275
|
+
**Available fields:**
|
|
276
|
+
- `firstName`, `lastName`
|
|
277
|
+
- `email`, `phone`
|
|
278
|
+
- `birthDate`, `addressTwo`
|
|
279
|
+
- `company`
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
283
|
+
firstName: 'John',
|
|
284
|
+
lastName: 'Doe',
|
|
285
|
+
email: 'john@example.com',
|
|
286
|
+
phone: '+15551234567',
|
|
287
|
+
birthDate: '1990-01-01',
|
|
288
|
+
addressTwo: 'Apt 4B',
|
|
289
|
+
company: 'Acme Corp'
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### actions.checkout.updateBillingInfo()
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
updateBillingInfo(params: Record<BillingFieldName, string>): void
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Pre-fill billing address.
|
|
300
|
+
|
|
301
|
+
**Available fields:**
|
|
302
|
+
- `firstName`, `lastName`
|
|
303
|
+
- `email`, `phone`, `company`
|
|
304
|
+
- `addressOne`, `addressTwo`
|
|
305
|
+
- `city`, `state`, `zipCode`
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
window.LiquidCommerce.elements.actions.checkout.updateBillingInfo({
|
|
309
|
+
firstName: 'John',
|
|
310
|
+
lastName: 'Doe',
|
|
311
|
+
email: 'john@example.com',
|
|
312
|
+
phone: '+15551234567',
|
|
313
|
+
company: 'Acme Corp',
|
|
314
|
+
addressOne: '123 Main St',
|
|
315
|
+
addressTwo: 'Apt 4B',
|
|
316
|
+
city: 'New York',
|
|
317
|
+
state: 'NY',
|
|
318
|
+
zipCode: '10001'
|
|
319
|
+
});
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### actions.checkout.updateGiftInfo()
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
updateGiftInfo(params: Record<GiftFieldName, string>): void
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Pre-fill gift recipient information.
|
|
329
|
+
|
|
330
|
+
**Available fields:**
|
|
331
|
+
- `firstName`, `lastName`
|
|
332
|
+
- `email`, `phone`
|
|
333
|
+
- `message`, `addressTwo`
|
|
334
|
+
|
|
335
|
+
```javascript
|
|
336
|
+
window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
|
|
337
|
+
firstName: 'Jane',
|
|
338
|
+
lastName: 'Smith',
|
|
339
|
+
email: 'jane@example.com',
|
|
340
|
+
phone: '+15559876543',
|
|
341
|
+
addressTwo: 'Suite 200',
|
|
342
|
+
message: 'Happy Birthday!',
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Payment Method
|
|
347
|
+
|
|
348
|
+
### actions.checkout.setSavedPaymentMethod()
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
setSavedPaymentMethod(params: {
|
|
352
|
+
id: string;
|
|
353
|
+
card: {
|
|
354
|
+
brand: string;
|
|
355
|
+
last4: string;
|
|
356
|
+
expMonth?: string | number;
|
|
357
|
+
expYear?: string | number;
|
|
358
|
+
};
|
|
359
|
+
}): void
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Pre-select a saved payment method for the checkout. When set, the payment step renders a read-only card summary (e.g. `Visa ending in 4242`) instead of the Stripe card form, and the shopper places the order without re-entering card details. The `id` is bound to the checkout when the payment form is saved.
|
|
363
|
+
|
|
364
|
+
`id` must be a payment method the backend already holds for the checkout's customer (for example, a card fetched server-side and handed to the page). If the backend does not recognize the `id` for this checkout's customer, saving the payment step fails with an error (`The selected payment method could not be applied to this checkout.`) and the order cannot be placed — pass only a payment method confirmed to belong to the customer. The `card` fields are used only to render the summary. It can be set at any time — before opening checkout, or while it is open — and the payment step updates accordingly. The selection persists across a cart reset within the session.
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
window.LiquidCommerce.elements.actions.checkout.setSavedPaymentMethod({
|
|
368
|
+
id: 'pm_123',
|
|
369
|
+
card: { brand: 'Visa', last4: '4242', expMonth: '12', expYear: '30' }
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### actions.checkout.clearSavedPaymentMethod()
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
clearSavedPaymentMethod(): void
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Remove a previously set saved payment method, restoring the Stripe card-entry form.
|
|
380
|
+
|
|
381
|
+
```javascript
|
|
382
|
+
window.LiquidCommerce.elements.actions.checkout.clearSavedPaymentMethod();
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Data Retrieval
|
|
386
|
+
|
|
387
|
+
### actions.checkout.getDetails()
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
getDetails(): ICheckoutDetailsEventData
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Retrieve current checkout information.
|
|
394
|
+
|
|
395
|
+
```javascript
|
|
396
|
+
const checkout = window.LiquidCommerce.elements.actions.checkout.getDetails();
|
|
397
|
+
|
|
398
|
+
console.log(`Cart ID: ${checkout.cartId}`);
|
|
399
|
+
console.log(`Total: $${checkout.amounts.total / 100}`);
|
|
400
|
+
console.log(`Items: ${checkout.itemCount}`);
|
|
401
|
+
console.log(`Is Gift: ${checkout.isGift}`);
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Returns:**
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
interface ICheckoutDetailsEventData {
|
|
408
|
+
deliveryScheduling: Record<string, CheckoutDeliveryScheduling>; // keyed by fulfillment ID; empty without scheduled delivery
|
|
409
|
+
token: string;
|
|
410
|
+
cartId: string;
|
|
411
|
+
isGift: boolean;
|
|
412
|
+
billingSameAsShipping: boolean;
|
|
413
|
+
marketingPreferences: {
|
|
414
|
+
canEmail: boolean;
|
|
415
|
+
canSms: boolean;
|
|
416
|
+
};
|
|
417
|
+
hasPromoCode: boolean;
|
|
418
|
+
hasGiftCards: boolean;
|
|
419
|
+
amounts: ICheckoutAmounts;
|
|
420
|
+
itemCount: number;
|
|
421
|
+
items: Record<string, ICheckoutItem>;
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### actions.checkout.getProductAvailabilityByState()
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
getProductAvailabilityByState(
|
|
429
|
+
identifiers: string[],
|
|
430
|
+
state?: string
|
|
431
|
+
): Promise<IProductAvailabilityResponse>
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Check product availability across states from the checkout context.
|
|
435
|
+
|
|
436
|
+
```javascript
|
|
437
|
+
const availability = await window.LiquidCommerce.elements.actions.checkout
|
|
438
|
+
.getProductAvailabilityByState(['00619947000020'], 'CA');
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
| Parameter | Type | Required | Description |
|
|
442
|
+
|---------------|----------|----------|--------------------------------------|
|
|
443
|
+
| `identifiers` | string[] | Yes | Array of product UPCs, SKUs, or IDs |
|
|
444
|
+
| `state` | string | No | Two-letter state code (e.g., `'NY'`) |
|
|
445
|
+
|
|
446
|
+
## Delivery scheduling actions
|
|
447
|
+
|
|
448
|
+
Available on both `Elements()` and `ElementsCheckout()` when a checkout fulfillment carries `deliveryScheduling` (an AccelPay retailer with scheduled delivery turned on). Checkouts without it keep their usual behaviour, and `getDetails().deliveryScheduling` is an empty map.
|
|
449
|
+
|
|
450
|
+
### `actions.checkout.loadDeliverySlots(fulfillmentId)`
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
loadDeliverySlots(fulfillmentId: string): Promise<DeliverySlot[]>
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Loads the full list of delivery windows for one fulfillment. Checkout prepare returns the list only on request, so outside this call `deliveryScheduling.slots` is empty and `availability.nextSlot` names the first window. The call sends the whole current checkout to prepare, plus `deliverySlotsFulfillmentId`, and resolves with the windows that can still be ordered. Each window's `cutoff` is the latest time to place the order for it ("Order by"). Show times in `availability.timezone`.
|
|
457
|
+
|
|
458
|
+
### `actions.checkout.chooseDeliverySlot(fulfillmentId, slotId)`
|
|
459
|
+
|
|
460
|
+
```typescript
|
|
461
|
+
chooseDeliverySlot(fulfillmentId: string, slotId: string | null): Promise<void>
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Saves a window from the last loaded list for one fulfillment, or `null` for as soon as possible (only when `availability.canDeliverNow` is true). The promise resolves after prepare accepts and echoes that exact selection. It rejects malformed arguments, unknown fulfillments, windows that were not offered, concurrent checkout updates, a checkout with more than one fulfillment group (only a checkout with one group can be scheduled) and server errors; a rejected save keeps the previously accepted choice, except after `delivery_selection_not_accepted` (below). Slot IDs come from the server; do not build them.
|
|
465
|
+
|
|
466
|
+
`getDetails().deliveryScheduling[fulfillmentId]` returns the availability, the accepted `selectedSlotId` and `selectedSlot` (the accepted window's `start`, `end` and `cutoff`).
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
const actions = client.actions.checkout;
|
|
470
|
+
const [fulfillmentId] = Object.keys(actions.getDetails().deliveryScheduling);
|
|
471
|
+
if (fulfillmentId) {
|
|
472
|
+
const slots = await actions.loadDeliverySlots(fulfillmentId);
|
|
473
|
+
if (slots.length) await actions.chooseDeliverySlot(fulfillmentId, slots[0].id);
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Expired windows
|
|
478
|
+
|
|
479
|
+
If a saved window's cutoff passes, or the store's hours or zone rules no longer allow it, before the order is placed, the server answers Place Order, or any other checkout update, with error code `delivery_window_expired` or `delivery_window_unavailable`. Both are recovered the same way; only the message differs ("Your delivery window has passed. Choose a new delivery time." or "Your delivery window is no longer available. Choose a new delivery time."). The SDK then clears the window, marks the fulfillment as needing a new choice, shows the message, opens the picker and blocks payment and Place Order until the shopper saves a new choice. An update that hit the error is sent once more without the window, so the shopper's change still applies. Customer, address, payment, tip and notes stay as they were. A custom UI recovers the same way: load the windows again and call `chooseDeliverySlot`.
|
|
480
|
+
|
|
481
|
+
If prepare did not keep the window that was sent (error code `delivery_selection_not_accepted`, HTTP 409), the SDK drops the window it holds for that fulfillment so no later update sends it again. `chooseDeliverySlot` rejects with "We couldn't save that delivery time. Choose a delivery time again."; on any other update the window is recovered as an unavailable one.
|
|
482
|
+
|
|
483
|
+
When scheduled delivery stops applying to the order (`delivery_scheduling_not_enabled`, `delivery_windows_unsupported`, `multiple_fulfillment_groups` or `delivery_scheduling_unsupported`), the SDK drops the saved window with a re-prepare, keeps the rest of checkout and shows "Scheduled delivery isn't available for this order right now. We'll deliver as soon as possible." The picker does not open; the response no longer carries `deliveryScheduling`, so the delivery time row goes away. Switching the delivery method never carries a window over to the new fulfillment.
|
|
484
|
+
|
|
485
|
+
## Use Cases
|
|
486
|
+
|
|
487
|
+
### Pre-fill for Logged-In Users
|
|
488
|
+
|
|
489
|
+
```javascript
|
|
490
|
+
window.addEventListener('lce:actions.checkout_opened', () => {
|
|
491
|
+
if (userIsLoggedIn) {
|
|
492
|
+
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
|
|
493
|
+
firstName: currentUser.firstName,
|
|
494
|
+
lastName: currentUser.lastName,
|
|
495
|
+
email: currentUser.email,
|
|
496
|
+
phone: currentUser.phone
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Track Checkout Progress
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
window.addEventListener('lce:actions.checkout_customer_information_updated', () => {
|
|
506
|
+
gtag('event', 'checkout_progress', { step: 'customer_info' });
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
window.addEventListener('lce:actions.checkout_submit_started', () => {
|
|
510
|
+
gtag('event', 'checkout_progress', { step: 'payment' });
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
window.addEventListener('lce:actions.checkout_submit_completed', (event) => {
|
|
514
|
+
const { orderNumber, orderTotal } = event.detail.data;
|
|
515
|
+
|
|
516
|
+
gtag('event', 'purchase', {
|
|
517
|
+
transaction_id: orderNumber,
|
|
518
|
+
value: orderTotal / 100,
|
|
519
|
+
currency: 'USD'
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Gift Flow
|
|
525
|
+
|
|
526
|
+
```javascript
|
|
527
|
+
document.getElementById('gift-checkbox').addEventListener('change', async (e) => {
|
|
528
|
+
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(e.target.checked);
|
|
529
|
+
|
|
530
|
+
if (e.target.checked) {
|
|
531
|
+
showGiftForm();
|
|
532
|
+
} else {
|
|
533
|
+
hideGiftForm();
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Auto-Apply Campaign Codes
|
|
539
|
+
|
|
540
|
+
```javascript
|
|
541
|
+
const params = new URLSearchParams(window.location.search);
|
|
542
|
+
const campaignCode = params.get('promo');
|
|
543
|
+
|
|
544
|
+
if (campaignCode) {
|
|
545
|
+
window.addEventListener('lce:actions.checkout_opened', async () => {
|
|
546
|
+
try {
|
|
547
|
+
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode(campaignCode);
|
|
548
|
+
} catch (error) {
|
|
549
|
+
console.log('Invalid campaign code');
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
## Events
|
|
556
|
+
|
|
557
|
+
Checkout actions trigger numerous events. See [Checkout Events](../../guides/events.md#checkout-events) for complete list.
|
|
558
|
+
|
|
559
|
+
Key events:
|
|
560
|
+
- `checkout_opened`, `checkout_closed`
|
|
561
|
+
- `checkout_customer_information_updated`
|
|
562
|
+
- `checkout_submit_started`, `checkout_submit_completed`, `checkout_submit_failed`
|
|
563
|
+
- `checkout_promo_code_applied`, `checkout_promo_code_failed`
|
|
564
|
+
- `checkout_gift_card_applied`, `checkout_gift_card_failed`
|
|
565
|
+
|
|
566
|
+
## See Also
|
|
567
|
+
|
|
568
|
+
- [Checkout Component Guide](../../guides/checkout-component.md)
|
|
569
|
+
- [Checkout Events](../../guides/events.md#checkout-events)
|
|
570
|
+
- [Cart Actions](./cart-actions.md)
|
|
571
|
+
|
|
572
|
+
### Preparing complete account delivery details
|
|
573
|
+
|
|
574
|
+
After `lce:actions.checkout_loaded`, call
|
|
575
|
+
`await elements.actions.checkout.updateCustomerInfo(fields, { saveIfValid: true })`
|
|
576
|
+
to validate and prepare complete account details, then show their editable summary.
|
|
577
|
+
Supply names, email, a US phone number, and a real `birthDate` in `MM/DD/YYYY` format
|
|
578
|
+
(age 21+, year 1930 or later). The `birthDate` may be blank when the partner does not require a
|
|
579
|
+
date of birth (`checkout.layout.requireBirthDate: false`); a supplied one is still validated.
|
|
580
|
+
A shipping street must already be selected.
|
|
581
|
+
Omitted apartment and delivery instructions retain their existing checkout values.
|
|
582
|
+
Partial or invalid details stay in the form; backend validation failures reject the
|
|
583
|
+
promise, show the checkout error, and keep details editable. The host should handle that rejection.
|
|
584
|
+
|
|
585
|
+
The option skips gifts, saved forms, in-flight saves, and customer forms the shopper
|
|
586
|
+
has edited during the current checkout. It does not overwrite those forms. Edits or
|
|
587
|
+
address/checkout changes during preparation prevent a stale response from closing
|
|
588
|
+
the form. Without the option, this action only prefills fields, as before.
|
|
589
|
+
|
|
590
|
+
Apple Pay and Google Pay selection displays **Continue with Apple Pay** or
|
|
591
|
+
**Continue with Google Pay**. This opens the wallet to save a payment method; the
|
|
592
|
+
shopper still reviews and places the order afterward. It is not express checkout.
|
|
593
|
+
|
|
594
|
+
After wallet cancellation, the same Continue action remains available. If authorization
|
|
595
|
+
succeeded but saving the method failed, **Retry saving Apple Pay/Google Pay** reuses
|
|
596
|
+
the existing authorization rather than opening the wallet again.
|
|
597
|
+
|
|
598
|
+
### Saved account marketing preferences
|
|
599
|
+
|
|
600
|
+
```ts
|
|
601
|
+
setSavedMarketingPreferences(preferences: { canEmail?: boolean; canSms?: boolean }): Promise<void>
|
|
602
|
+
clearSavedMarketingPreferences(): void
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
Call `actions.checkout.setSavedMarketingPreferences()` with known recorded account
|
|
606
|
+
choices, including `false`, before checkout loads. Only boolean values are used;
|
|
607
|
+
missing/null/unrecognized values remain unknown. The first checkout prepare uses
|
|
608
|
+
saved values instead of tenant defaults. Each channel's prompt is hidden only
|
|
609
|
+
after the server confirms that saved choice. Unknown channels retain their normal
|
|
610
|
+
checkout prompts. The actions are available in both full and checkout-only clients.
|
|
611
|
+
|
|
612
|
+
Calling the setter during an active checkout prepares untouched channels and
|
|
613
|
+
preserves shopper checkbox edits. Backend failure rejects the promise, displays
|
|
614
|
+
an error, and leaves prompts available; the host should catch the rejection.
|
|
615
|
+
The same call can retry. Applying values does not call a subscription service.
|
|
616
|
+
It supplies the account's recorded choices to this checkout.
|
|
617
|
+
|
|
618
|
+
Saved choices persist across cart resets in the same SDK session. Call
|
|
619
|
+
`clearSavedMarketingPreferences()` on sign-out, account change, and host cleanup.
|
|
620
|
+
Clearing reveals the prompts and restores configured guest defaults. It invalidates
|
|
621
|
+
stale responses while draining outstanding preference requests; checkout completion
|
|
622
|
+
prepares the current choices before submitting the checkout token. A load already
|
|
623
|
+
in progress still finishes and reconciles the current account's values. Bind a new
|
|
624
|
+
account only to its own checkout; the host remains responsible for account/cart
|
|
625
|
+
ownership and for reloading checkout when identity changes.
|
|
626
|
+
|
|
627
|
+
Order completion waits for queued preference work. It cannot race a late saved
|
|
628
|
+
opt-out or proceed with an unconfirmed saved choice. If applying a known choice
|
|
629
|
+
fails, the shopper can retry or explicitly choose the visible channel preference.
|