@liquidcommerce/elements-sdk 2.6.0-beta.11 → 2.6.0-beta.110
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 +99 -2518
- package/dist/index.checkout.esm.js +18210 -0
- package/dist/index.esm.js +26253 -20673
- package/dist/ssr-stub.checkout.esm.js +17 -0
- package/dist/ssr-stub.esm.js +269 -0
- package/dist/types/auto-initialize/checkout.d.ts +2 -0
- package/dist/types/auto-initialize/shared-utils.d.ts +50 -0
- package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +15 -2
- package/dist/types/clients/builder.d.ts +3 -0
- package/dist/types/clients/checkout.d.ts +6 -0
- package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +2 -1
- package/dist/types/clients/main.d.ts +3 -0
- package/dist/types/constants/core.constant.d.ts +13 -18
- 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 +19 -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 +69 -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 +8 -5
- package/dist/types/core/debug-panel/debug-panel.styles.d.ts +1 -1
- package/dist/types/core/google-tag-manager.service.d.ts +3 -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 +1 -1
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +36 -51
- package/dist/types/core/pubsub/interfaces/core.interface.d.ts +11 -6
- 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 +19 -108
- 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 +39 -2
- package/dist/types/enums/index.d.ts +0 -1
- package/dist/types/index.checkout.d.ts +8 -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 +239 -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 +72 -0
- package/dist/types/interfaces/component.interface.d.ts +7 -0
- package/dist/types/interfaces/config.interface.d.ts +40 -0
- package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
- package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -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 +5 -1
- package/dist/types/interfaces/injection.interface.d.ts +50 -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 +4 -4
- package/dist/types/modules/cart/components/cart-body.component.d.ts +1 -0
- 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 +34 -11
- package/dist/types/modules/checkout/checkout.component.d.ts +6 -1
- package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +5 -2
- package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +5 -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 +2 -0
- package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +2 -1
- package/dist/types/modules/checkout/components/checkout-place-order-button.component.d.ts +2 -0
- 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-send-as-gift.component.d.ts +3 -0
- package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +4 -2
- package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +4 -2
- 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 +3 -0
- package/dist/types/modules/checkout/payment-session-error.d.ts +4 -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/product-add-to-cart-section.component.d.ts +7 -1
- 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-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/product.commands.d.ts +5 -5
- package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -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-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 +37 -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 +53 -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 +1 -1
- 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 +8 -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 +14 -1
- 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 +5 -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 +18 -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 +527 -0
- package/docs/v1/api/actions/product-actions.md +204 -0
- package/docs/v1/api/client.md +596 -0
- package/docs/v1/api/configuration.md +557 -0
- package/docs/v1/api/injection-methods.md +331 -0
- package/docs/v1/api/typescript-types.md +424 -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 +63 -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 +349 -0
- package/docs/v1/getting-started/quick-start.md +410 -0
- package/docs/v1/guides/accessibility.md +214 -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 +757 -0
- package/docs/v1/guides/checkout-component.md +670 -0
- package/docs/v1/guides/events.md +939 -0
- package/docs/v1/guides/product-component.md +736 -0
- package/docs/v1/guides/product-list-component.md +730 -0
- package/docs/v1/guides/theming.md +229 -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 +107 -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.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
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconProps } from './icon.types';
|
|
2
|
-
export declare const TrashIcon: ({ width, height, className, color }: IconProps) => string;
|
|
2
|
+
export declare const TrashIcon: ({ width, height, className, color, label }: IconProps) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconProps } from './icon.types';
|
|
2
|
-
export declare const WarningIcon: ({ width, height, className, color }: IconProps) => string;
|
|
2
|
+
export declare const WarningIcon: ({ width, height, className, color, label }: IconProps) => string;
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
export declare function centToDollar(cent: number): number;
|
|
2
2
|
export declare function formatCentToDollarText(cent: number, showZeroDecimals?: boolean): string;
|
|
3
3
|
export declare function htmlStringToElement(htmlString: string): HTMLElement;
|
|
4
|
-
export declare function format24TimeTo12(time24h: string): string;
|
|
5
4
|
export declare function formatISODateToMMDDYYYY(isoDateString: string | null | undefined): string;
|
|
6
|
-
export declare function
|
|
7
|
-
isValid: boolean;
|
|
8
|
-
age: number | null;
|
|
9
|
-
error?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function buildFormattedAddressString(address: {
|
|
12
|
-
one: string;
|
|
13
|
-
two: string;
|
|
14
|
-
city: string;
|
|
15
|
-
state: string;
|
|
16
|
-
zip: string;
|
|
17
|
-
country?: string;
|
|
18
|
-
}): string;
|
|
5
|
+
export declare function formatISOInstantToMMDDYYYY(isoInstant: string | null | undefined, timeZone?: string): string;
|
|
19
6
|
export declare function capitalizeFirstLetter(text: string): string;
|
|
20
7
|
export declare function splitCategoryPath(catPath?: string): {
|
|
21
8
|
category: string;
|
|
22
9
|
category2: string;
|
|
23
10
|
category3: string;
|
|
24
11
|
};
|
|
12
|
+
export declare function normalizeEngravingLines(lines: readonly (string | null | undefined)[] | null | undefined): string[];
|
|
13
|
+
export declare function normalizeText<T extends string | null | undefined>(value: T): T;
|
|
14
|
+
export declare function normalizeEmail<T extends string | null | undefined>(value: T): T;
|
|
15
|
+
export declare function normalizeCode<T extends string | null | undefined>(value: T): T;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IProductFulfillmentStore, IProductSizeStore } from '@/core/store/interfaces/product.interface';
|
|
2
|
+
import { type FulfillmentType } from '@/enums';
|
|
3
|
+
export interface ISizeSelectionResult {
|
|
4
|
+
selectedFulfillmentType: FulfillmentType;
|
|
5
|
+
selectedFulfillment: IProductFulfillmentStore | null;
|
|
6
|
+
selectedFulfillmentId: string | null;
|
|
7
|
+
productHasAvailability: boolean;
|
|
8
|
+
fulfillmentHasAvailability: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface IFulfillmentTypeChangeResult {
|
|
11
|
+
selectedFulfillment: IProductFulfillmentStore | null;
|
|
12
|
+
selectedFulfillmentId: string | null;
|
|
13
|
+
fulfillmentHasAvailability: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function calculateSizeSelection(productSize: IProductSizeStore, currentFulfillmentType: FulfillmentType): ISizeSelectionResult;
|
|
16
|
+
export declare function calculateFulfillmentTypeChange(productSize: IProductSizeStore, newFulfillmentType: FulfillmentType): IFulfillmentTypeChangeResult | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IProductStore } from '@/core/store/interfaces/product.interface';
|
|
2
|
+
import type { IPLProductStore } from '@/core/store/interfaces/product-list.interface';
|
|
3
|
+
import { type FulfillmentType } from '@/enums';
|
|
4
|
+
import type { IProduct, IProductAvailabilityResponse } from '@/interfaces/api/product.interface';
|
|
5
|
+
export interface IPrepareApiProductForStoreParams {
|
|
6
|
+
context: 'product-list' | 'product-page';
|
|
7
|
+
product: IProduct;
|
|
8
|
+
retailers: IProductAvailabilityResponse['retailers'];
|
|
9
|
+
enableShippingFulfillment: boolean;
|
|
10
|
+
enableOnDemandFulfillment?: boolean;
|
|
11
|
+
primaryFulfillmentMethod?: FulfillmentType;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildSizeLabel(size: {
|
|
14
|
+
size: string;
|
|
15
|
+
pack: boolean;
|
|
16
|
+
packDesc: string;
|
|
17
|
+
}): string;
|
|
18
|
+
export declare function prepareApiProductForStore({ context, product, retailers, enableShippingFulfillment, enableOnDemandFulfillment, primaryFulfillmentMethod, }: IPrepareApiProductForStoreParams): IProductStore | IPLProductStore;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export declare const BUSINESS_CONTRACT_TIMEZONE = "America/New_York";
|
|
2
|
+
export declare function getDatePartsInTimezone(instant: Date, timeZone: string): {
|
|
3
|
+
year: string;
|
|
4
|
+
month: string;
|
|
5
|
+
day: string;
|
|
6
|
+
} | null;
|
|
1
7
|
export declare function detectUserTimezone(addressState?: string): string;
|
|
2
8
|
export declare function getCurrentTimeInTimezone(timezone: string): Date;
|
|
3
9
|
export declare function getCurrentTimeInUserTimezone(addressState?: string): Date;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Elements SDK v1 Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the comprehensive documentation for the LiquidCommerce Elements SDK v1.
|
|
4
|
+
|
|
5
|
+
## What is Elements SDK?
|
|
6
|
+
|
|
7
|
+
The Elements SDK is a Web Components-based e-commerce SDK that allows you to add product displays, shopping carts, and checkout flows to any website with minimal code.
|
|
8
|
+
|
|
9
|
+
## Quick Links
|
|
10
|
+
|
|
11
|
+
- **[Installation](./getting-started/installation.md)** - Get started in minutes
|
|
12
|
+
- **[Quick Start](./getting-started/quick-start.md)** - Build your first product page
|
|
13
|
+
- **[API Reference](./api/client.md)** - Complete API documentation
|
|
14
|
+
|
|
15
|
+
## Documentation Sections
|
|
16
|
+
|
|
17
|
+
### Getting Started
|
|
18
|
+
|
|
19
|
+
Essential guides for new users:
|
|
20
|
+
|
|
21
|
+
- **[Installation](./getting-started/installation.md)** - CDN, NPM, and framework integration
|
|
22
|
+
- **[Quick Start](./getting-started/quick-start.md)** - Your first product page in 5 minutes
|
|
23
|
+
- **[Core Concepts](./getting-started/concepts.md)** - Understand how the SDK works
|
|
24
|
+
|
|
25
|
+
### Component Guides
|
|
26
|
+
|
|
27
|
+
In-depth guides for each major component:
|
|
28
|
+
|
|
29
|
+
- **[Product Component](./guides/product-component.md)** - Display products with add-to-cart functionality
|
|
30
|
+
- **[Cart Component](./guides/cart-component.md)** - Shopping cart and item management
|
|
31
|
+
- **[Checkout Component](./guides/checkout-component.md)** - Complete purchase flow
|
|
32
|
+
- **[Address Component](./guides/address-component.md)** - Delivery location management
|
|
33
|
+
- **[Product List Component](./guides/product-list-component.md)** - Filterable product catalogs
|
|
34
|
+
- **[Theming](./guides/theming.md)** - Customize appearance and branding
|
|
35
|
+
- **[Accessibility](./guides/accessibility.md)** - Keyboard, screen reader, contrast and focus behaviour
|
|
36
|
+
- **[Events](./guides/events.md)** - Event system and subscriptions
|
|
37
|
+
- **[Best Practices](./guides/best-practices.md)** - Patterns, tips, and recommendations
|
|
38
|
+
|
|
39
|
+
### API Reference
|
|
40
|
+
|
|
41
|
+
Complete API documentation:
|
|
42
|
+
|
|
43
|
+
**Core API:**
|
|
44
|
+
- **[Client API](./api/client.md)** - Main SDK client interface
|
|
45
|
+
- **[Injection Methods](./api/injection-methods.md)** - Component injection
|
|
46
|
+
- **[UI Helpers](./api/ui-helpers.md)** - Cart buttons and UI elements
|
|
47
|
+
- **[Configuration](./api/configuration.md)** - All configuration options
|
|
48
|
+
- **[TypeScript Types](./api/typescript-types.md)** - Type definitions
|
|
49
|
+
|
|
50
|
+
**Actions API:**
|
|
51
|
+
- **[Product Actions](./api/actions/product-actions.md)** - `actions.product.*`
|
|
52
|
+
- **[Address Actions](./api/actions/address-actions.md)** - `actions.address.*`
|
|
53
|
+
- **[Cart Actions](./api/actions/cart-actions.md)** - `actions.cart.*`
|
|
54
|
+
- **[Checkout Actions](./api/actions/checkout-actions.md)** - `actions.checkout.*`
|
|
55
|
+
|
|
56
|
+
### Architecture (To Be Done In Future Versions)
|
|
57
|
+
|
|
58
|
+
Deep dive into SDK internals:
|
|
59
|
+
|
|
60
|
+
- **[Overview](./architecture/overview.md)** - System architecture
|
|
61
|
+
- **[Initialization](./architecture/initialization.md)** - Phased initialization process
|
|
62
|
+
- **[State Management](./architecture/state-management.md)** - Store service and persistence
|
|
63
|
+
- **[Event System](./architecture/event-system.md)** - PubSub architecture
|
|
64
|
+
- **[Web Components](./architecture/web-components.md)** - Component factory and Shadow DOM
|
|
65
|
+
- **[Build System](./architecture/build-system.md)** - Bundles and tree-shaking
|
|
66
|
+
|
|
67
|
+
### Framework Integration
|
|
68
|
+
|
|
69
|
+
Integration guides for popular frameworks:
|
|
70
|
+
|
|
71
|
+
- **[React](./integration/react.md)** - React integration patterns and hooks
|
|
72
|
+
- **[Next.js](./integration/nextjs.md)** - Next.js setup with SSR considerations
|
|
73
|
+
- **[Vue](./integration/vue.md)** - Vue component integration
|
|
74
|
+
- **[Angular](./integration/angular.md)** - Angular client-only setup
|
|
75
|
+
- **[Laravel](./integration/laravel.md)** - Blade + CDN integration
|
|
76
|
+
- **[Vanilla JavaScript](./integration/vanilla-js.md)** - Pure JavaScript integration
|
|
77
|
+
- **[Proxy Setup](./integration/proxy-setup.md)** - Ad blocker avoidance
|
|
78
|
+
|
|
79
|
+
### Reference
|
|
80
|
+
|
|
81
|
+
Technical reference and troubleshooting:
|
|
82
|
+
|
|
83
|
+
- **[Browser Support](./reference/browser-support.md)** - Compatibility matrix
|
|
84
|
+
- **[Troubleshooting](./reference/troubleshooting.md)** - Common issues and solutions
|
|
85
|
+
- **[Error Handling](./reference/error-handling.md)** - Error types and debugging
|
|
86
|
+
- **[Performance](./reference/performance.md)** - Optimization tips and best practices
|
|
87
|
+
- **[Analytics](./reference/analytics.md)** - Google Tag Manager / GA4 integration
|
|
88
|
+
- **[Telemetry](./reference/telemetry.md)** - What the SDK reports and how to control it
|
|
89
|
+
|
|
90
|
+
### Examples
|
|
91
|
+
|
|
92
|
+
Practical examples with working code:
|
|
93
|
+
|
|
94
|
+
- **[Simple Product Page](./examples/simple-product-page.md)** - Basic PDP implementation
|
|
95
|
+
- **[Multi-Product Page](./examples/multi-product-page.md)** - Multiple products on one page
|
|
96
|
+
- **[Complete Checkout Flow](./examples/checkout-flow.md)** - Full e-commerce flow
|
|
97
|
+
- **[Custom Theming](./examples/custom-theming.md)** - Brand customization examples
|
|
98
|
+
- **[Advanced Patterns](./examples/advanced-patterns.md)** - Complex integration scenarios
|
|
99
|
+
|
|
100
|
+
## Common Tasks
|
|
101
|
+
|
|
102
|
+
### Adding a Product
|
|
103
|
+
|
|
104
|
+
**Declarative (HTML):**
|
|
105
|
+
```html
|
|
106
|
+
<script
|
|
107
|
+
defer
|
|
108
|
+
data-liquid-commerce-elements
|
|
109
|
+
data-token="YOUR_API_KEY"
|
|
110
|
+
data-env="production"
|
|
111
|
+
data-container-1="product"
|
|
112
|
+
data-product-1="00619947000020"
|
|
113
|
+
type="text/javascript"
|
|
114
|
+
src="https://elements.reservebar-worker.workers.dev/all/elements.js"
|
|
115
|
+
></script>
|
|
116
|
+
|
|
117
|
+
<div id="product"></div>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Programmatic (JavaScript):**
|
|
121
|
+
```javascript
|
|
122
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
123
|
+
await client.injectProductElement([
|
|
124
|
+
{ containerId: 'product', identifier: '00619947000020' }
|
|
125
|
+
]);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Opening the Cart
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
window.LiquidCommerce.elements.actions.cart.openCart();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Adding to Cart Programmatically
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
await window.LiquidCommerce.elements.actions.cart.addProduct([
|
|
138
|
+
{
|
|
139
|
+
identifier: '00619947000020',
|
|
140
|
+
fulfillmentType: 'shipping',
|
|
141
|
+
quantity: 1
|
|
142
|
+
}
|
|
143
|
+
], true); // true = open cart after adding
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Listening for Events
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
window.addEventListener('lce:actions.cart_item_added', (event) => {
|
|
150
|
+
console.log('Item added to cart:', event.detail.data);
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Customizing Theme
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
const client = await Elements('YOUR_API_KEY', {
|
|
158
|
+
env: 'production',
|
|
159
|
+
customTheme: {
|
|
160
|
+
global: {
|
|
161
|
+
theme: {
|
|
162
|
+
primaryColor: '#007bff',
|
|
163
|
+
buttonCornerRadius: '8px'
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Key Concepts
|
|
171
|
+
|
|
172
|
+
### Web Components
|
|
173
|
+
The SDK uses native Web Components for framework-agnostic integration and style encapsulation.
|
|
174
|
+
|
|
175
|
+
### Shadow DOM
|
|
176
|
+
Components use Shadow DOM to prevent CSS conflicts and ensure consistent styling.
|
|
177
|
+
|
|
178
|
+
### Auto-Initialization
|
|
179
|
+
When using the CDN, the SDK automatically initializes based on HTML data attributes.
|
|
180
|
+
|
|
181
|
+
### Event-Driven
|
|
182
|
+
The SDK publishes events for all user interactions, allowing you to react to changes.
|
|
183
|
+
|
|
184
|
+
### State Persistence
|
|
185
|
+
Cart and address data persist across sessions using localStorage with API fallback.
|
|
186
|
+
|
|
187
|
+
## Browser Requirements
|
|
188
|
+
|
|
189
|
+
- Chrome 66+ (March 2018)
|
|
190
|
+
- Firefox 60+ (May 2018)
|
|
191
|
+
- Safari 12+ (September 2018)
|
|
192
|
+
- Edge 79+ (January 2020)
|
|
193
|
+
|
|
194
|
+
Requires Web Components and Shadow DOM support.
|
|
195
|
+
|
|
196
|
+
## Support
|
|
197
|
+
|
|
198
|
+
For assistance, contact your LiquidCommerce representative.
|
|
199
|
+
|
|
200
|
+
## Version History
|
|
201
|
+
|
|
202
|
+
This is the v1 documentation. Future versions will be documented in separate directories (`v2/`, `v3/`, etc.).
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
|
|
206
|
+
Found an issue in the documentation? Contact your LiquidCommerce representative with suggestions.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Navigation
|
|
211
|
+
|
|
212
|
+
- [← Back to Repository](../)
|
|
213
|
+
- [Getting Started →](./getting-started/installation.md)
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Address Actions API
|
|
2
|
+
|
|
3
|
+
Address actions allow you to programmatically manage the delivery location.
|
|
4
|
+
|
|
5
|
+
## actions.address.setAddressByPlacesId()
|
|
6
|
+
|
|
7
|
+
Set address using a Google Places ID.
|
|
8
|
+
|
|
9
|
+
### Signature
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
setAddressByPlacesId(placesId: string): Promise<void>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Required | Description |
|
|
18
|
+
|-----------|------|----------|-------------|
|
|
19
|
+
| `placesId` | string | Yes | Google Places ID |
|
|
20
|
+
|
|
21
|
+
### Example
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(
|
|
25
|
+
'ChIJOwg_06VPwokRYv534QaPC8g'
|
|
26
|
+
);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### How to Get Places ID
|
|
30
|
+
|
|
31
|
+
Visit [Google Place IDs](https://developers.google.com/maps/documentation/places/web-service/place-id#find-id) for details on obtaining a Places ID.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## actions.address.setAddressManually()
|
|
36
|
+
|
|
37
|
+
Set address manually without Google Places.
|
|
38
|
+
|
|
39
|
+
### Signature
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
setAddressManually(
|
|
43
|
+
address: IAddressAddress,
|
|
44
|
+
coordinates: IAddressCoordinates
|
|
45
|
+
): Promise<void>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Parameters
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
interface IAddressAddress {
|
|
52
|
+
one: string; // Street address
|
|
53
|
+
two: string; // Apt, suite, etc.
|
|
54
|
+
city: string; // City name
|
|
55
|
+
state: string; // Two-letter state code
|
|
56
|
+
zip: string; // ZIP/postal code
|
|
57
|
+
country: string; // Country
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface IAddressCoordinates {
|
|
61
|
+
latitude: number; // -90 to 90
|
|
62
|
+
longitude: number; // -180 to 180
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Example
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(
|
|
70
|
+
{
|
|
71
|
+
one: '123 Main Street',
|
|
72
|
+
two: 'Apt 4',
|
|
73
|
+
city: 'New York',
|
|
74
|
+
state: 'NY',
|
|
75
|
+
zip: '10001',
|
|
76
|
+
country: 'US'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
latitude: 40.7128,
|
|
80
|
+
longitude: -74.0060
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Validation
|
|
86
|
+
|
|
87
|
+
The SDK validates:
|
|
88
|
+
- All required fields are present (street, city, state, zip)
|
|
89
|
+
- Latitude is between -90 and 90
|
|
90
|
+
- Longitude is between -180 and 180
|
|
91
|
+
|
|
92
|
+
> Note: the `state` field is expected to be a 2-letter code by convention, but the SDK does **not** enforce its format.
|
|
93
|
+
|
|
94
|
+
### Errors
|
|
95
|
+
|
|
96
|
+
**Throws `SDKError` if:**
|
|
97
|
+
- `address` or `coordinates` is missing
|
|
98
|
+
- A required field is missing (street, city, state, zip)
|
|
99
|
+
- Latitude or longitude is non-numeric
|
|
100
|
+
- Coordinates are out of range (latitude outside -90..90, longitude outside -180..180)
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## actions.address.clear()
|
|
105
|
+
|
|
106
|
+
Remove the current address.
|
|
107
|
+
|
|
108
|
+
### Signature
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
clear(): Promise<void>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Example
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
await window.LiquidCommerce.elements.actions.address.clear();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Effects
|
|
121
|
+
|
|
122
|
+
- Clears stored address
|
|
123
|
+
- Products will prompt for address on next add-to-cart
|
|
124
|
+
- Cart/checkout require re-entering address
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## actions.address.getDetails()
|
|
129
|
+
|
|
130
|
+
Retrieve the current address.
|
|
131
|
+
|
|
132
|
+
### Signature
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
getDetails(): IAddressData | null
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Returns
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface IAddressData {
|
|
142
|
+
id: string; // Google Places ID (always populated when an object is returned)
|
|
143
|
+
address: {
|
|
144
|
+
one: string;
|
|
145
|
+
two: string;
|
|
146
|
+
city: string;
|
|
147
|
+
state: string;
|
|
148
|
+
zip: string;
|
|
149
|
+
country: string;
|
|
150
|
+
};
|
|
151
|
+
coordinates: {
|
|
152
|
+
latitude: number;
|
|
153
|
+
longitude: number;
|
|
154
|
+
};
|
|
155
|
+
formattedAddress: string;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Returns `null` if no address is set. Manually-entered addresses (set via `setAddressManually`) are stored without a Google Places ID, so `getDetails()` also returns `null` for them.
|
|
160
|
+
|
|
161
|
+
### Example
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
const address = window.LiquidCommerce.elements.actions.address.getDetails();
|
|
165
|
+
|
|
166
|
+
if (address) {
|
|
167
|
+
console.log('Current address:', address.formattedAddress);
|
|
168
|
+
console.log('Coordinates:', address.coordinates);
|
|
169
|
+
} else {
|
|
170
|
+
console.log('No address set');
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Use Cases
|
|
175
|
+
|
|
176
|
+
#### Check if Address is Set
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
if (!window.LiquidCommerce.elements.actions.address.getDetails()) {
|
|
180
|
+
// Prompt user to set address
|
|
181
|
+
showAddressPrompt();
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Display Current Address
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
const address = window.LiquidCommerce.elements.actions.address.getDetails();
|
|
189
|
+
|
|
190
|
+
if (address) {
|
|
191
|
+
document.getElementById('current-address').textContent =
|
|
192
|
+
address.formattedAddress;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
## Events
|
|
196
|
+
|
|
197
|
+
Address actions trigger events:
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// Address updated
|
|
201
|
+
window.addEventListener('lce:actions.address_updated', (event) => {
|
|
202
|
+
const { googlePlacesId, address, coordinates, formattedAddress } = event.detail.data;
|
|
203
|
+
console.log('Address set:', formattedAddress);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Address cleared
|
|
207
|
+
window.addEventListener('lce:actions.address_cleared', () => {
|
|
208
|
+
console.log('Address cleared');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Address failed
|
|
212
|
+
window.addEventListener('lce:actions.address_failed', (event) => {
|
|
213
|
+
console.error('Address error:', event.detail.data.error);
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Best Practices
|
|
218
|
+
|
|
219
|
+
### Use Places ID When Available
|
|
220
|
+
|
|
221
|
+
Google Places provides accurate geocoding:
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
// Good - accurate and validated
|
|
225
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(placesId);
|
|
226
|
+
|
|
227
|
+
// Less ideal - requires manual geocoding
|
|
228
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Validate Manual Addresses
|
|
232
|
+
|
|
233
|
+
When using manual address entry:
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
async function setManualAddress(address, coords) {
|
|
237
|
+
// Validate format
|
|
238
|
+
if (!address.one || !address.city || !address.state || !address.zip) {
|
|
239
|
+
throw new Error('Missing required fields');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Validate state
|
|
243
|
+
if (!/^[A-Z]{2}$/.test(address.state)) {
|
|
244
|
+
throw new Error('State must be 2-letter code');
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Validate ZIP
|
|
248
|
+
if (!/^\d{5}(-\d{4})?$/.test(address.zip)) {
|
|
249
|
+
throw new Error('Invalid ZIP code');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Handle Errors
|
|
257
|
+
|
|
258
|
+
```javascript
|
|
259
|
+
try {
|
|
260
|
+
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(placesId);
|
|
261
|
+
showSuccess('Address saved!');
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.error('Failed to set address:', error);
|
|
264
|
+
showError('Unable to set that address. Please try again.');
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Set Address Early
|
|
269
|
+
|
|
270
|
+
Set address as soon as possible in user flow:
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
274
|
+
if (!window.LiquidCommerce.elements.actions.address.getDetails()) {
|
|
275
|
+
// Prompt for address on first visit
|
|
276
|
+
showAddressModal();
|
|
277
|
+
}
|
|
278
|
+
}, { once: true });
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## See Also
|
|
282
|
+
|
|
283
|
+
- [Address Component Guide](../../guides/address-component.md)
|
|
284
|
+
- [Address Events](../../guides/events.md#address-events)
|
|
285
|
+
- [Product Component](../../guides/product-component.md#address-requirement)
|
|
286
|
+
- [Cart Component](../../guides/cart-component.md#address-requirement)
|