@liquidcommerce/elements-sdk 2.7.0 → 2.7.1
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 +83 -2750
- package/dist/index.checkout.esm.js +6877 -6825
- package/dist/index.esm.js +11384 -10940
- package/dist/types/auto-initialize/shared-utils.d.ts +5 -0
- package/dist/types/constants/core.constant.d.ts +0 -4
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +1 -0
- package/dist/types/enums/core.enum.d.ts +11 -0
- package/dist/types/interfaces/configs/product-list.interface.d.ts +2 -2
- package/dist/types/modules/address/address-input.component.d.ts +11 -0
- package/dist/types/modules/product-list/components/card-components/index.d.ts +3 -0
- package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +8 -0
- package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts +2 -0
- package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
- package/dist/types/modules/product-list/components/card-components/product-title.d.ts +6 -0
- package/dist/types/modules/product-list/components/index.d.ts +1 -0
- package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +5 -1
- package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +28 -0
- package/dist/types/modules/product-list/components/product-list-retailers.component.d.ts +10 -2
- package/dist/types/modules/product-list/product-list-card.component.d.ts +0 -5
- package/dist/types/modules/product-list/product-list.commands.d.ts +11 -2
- package/dist/types/modules/product-list/product-list.interface.d.ts +1 -0
- package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +11 -2
- package/docs/gitbook/actions.md +160 -0
- package/docs/gitbook/address.md +48 -0
- package/docs/gitbook/cart.md +65 -0
- package/docs/gitbook/checkout.md +131 -0
- package/docs/gitbook/events.md +137 -0
- package/docs/gitbook/overview.md +166 -0
- package/docs/gitbook/product.md +64 -0
- package/docs/gitbook/quick-start-guide.md +393 -0
- package/docs/v1/README.md +210 -0
- package/docs/v1/api/actions/address-actions.md +281 -0
- package/docs/v1/api/actions/cart-actions.md +337 -0
- package/docs/v1/api/actions/checkout-actions.md +387 -0
- package/docs/v1/api/actions/product-actions.md +115 -0
- package/docs/v1/api/client.md +482 -0
- package/docs/v1/api/configuration.md +1 -0
- package/docs/v1/api/injection-methods.md +247 -0
- package/docs/v1/api/typescript-types.md +1 -0
- package/docs/v1/api/ui-helpers.md +200 -0
- package/docs/v1/examples/advanced-patterns.md +96 -0
- package/docs/v1/examples/checkout-flow.md +91 -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 +507 -0
- package/docs/v1/getting-started/installation.md +328 -0
- package/docs/v1/getting-started/quick-start.md +405 -0
- package/docs/v1/guides/address-component.md +431 -0
- package/docs/v1/guides/best-practices.md +324 -0
- package/docs/v1/guides/cart-component.md +737 -0
- package/docs/v1/guides/checkout-component.md +672 -0
- package/docs/v1/guides/events.md +191 -0
- package/docs/v1/guides/product-component.md +686 -0
- package/docs/v1/guides/product-list-component.md +598 -0
- package/docs/v1/guides/theming.md +216 -0
- package/docs/v1/integration/angular.md +39 -0
- package/docs/v1/integration/laravel.md +41 -0
- package/docs/v1/integration/nextjs.md +60 -0
- package/docs/v1/integration/proxy-setup.md +89 -0
- package/docs/v1/integration/react.md +64 -0
- package/docs/v1/integration/vanilla-js.md +84 -0
- package/docs/v1/integration/vue.md +34 -0
- package/docs/v1/reference/browser-support.md +35 -0
- package/docs/v1/reference/error-handling.md +70 -0
- package/docs/v1/reference/performance.md +54 -0
- package/docs/v1/reference/troubleshooting.md +64 -0
- package/package.json +1 -1
- package/docs/ACTIONS.md +0 -1301
- package/docs/BROWSER_SUPPORT.md +0 -279
- package/docs/CONFIGURATION.md +0 -997
- package/docs/DOCUMENTATION_INDEX.md +0 -319
- package/docs/EVENTS.md +0 -798
- package/docs/PROXY.md +0 -228
- package/docs/THEMING.md +0 -681
- package/docs/TROUBLESHOOTING.md +0 -793
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { IInjectCheckoutParams, IInjectedComponent, ILiquidCommerceElementsDevelopmentConfig } from '@/interfaces/core.interface';
|
|
2
2
|
export declare const SHARED_ATTR: {
|
|
3
3
|
readonly SCRIPT: {
|
|
4
|
+
readonly MAIN: "data-liquid-commerce-elements";
|
|
5
|
+
readonly TOKEN: "data-token";
|
|
6
|
+
readonly ENV: "data-env";
|
|
7
|
+
readonly DEBUG_MODE: "data-debug-mode";
|
|
4
8
|
readonly CHECKOUT_PARAM: "data-checkout-param";
|
|
9
|
+
readonly CHECKOUT_URL: "data-checkout-url";
|
|
5
10
|
};
|
|
6
11
|
readonly ELEMENT: {
|
|
7
12
|
readonly CHECKOUT: "data-lce-checkout";
|
|
@@ -100,6 +100,7 @@ export declare const COMPONENT_TYPE: {
|
|
|
100
100
|
readonly PRODUCT_LIST_CARD_LOADING: "product-list-card-loading";
|
|
101
101
|
readonly PRODUCT_LIST_RETAILERS: "product-list-retailers";
|
|
102
102
|
readonly PRODUCT_LIST_ENGRAVING_FORM: "product-list-engraving-form";
|
|
103
|
+
readonly PRODUCT_LIST_PRODUCT_PRE_CART: "product-list-product-pre-cart";
|
|
103
104
|
readonly CART: "cart";
|
|
104
105
|
readonly CART_RETAILER: "cart-retailer";
|
|
105
106
|
readonly CART_ITEM: "cart-item";
|
|
@@ -172,3 +173,13 @@ export declare const CHECKOUT_EVENT_LEVEL: {
|
|
|
172
173
|
readonly ERROR: "error";
|
|
173
174
|
};
|
|
174
175
|
export type CheckoutEventLevel = (typeof CHECKOUT_EVENT_LEVEL)[keyof typeof CHECKOUT_EVENT_LEVEL];
|
|
176
|
+
export declare const DISPLAY_MODE: {
|
|
177
|
+
readonly MODAL: "modal";
|
|
178
|
+
readonly DRAWER: "drawer";
|
|
179
|
+
};
|
|
180
|
+
export type DisplayModeType = (typeof DISPLAY_MODE)[keyof typeof DISPLAY_MODE];
|
|
181
|
+
export declare const NAVIGATION_SOURCE: {
|
|
182
|
+
readonly PRODUCT_CARD: "productCard";
|
|
183
|
+
readonly ADD_TO_CART_DRAWER: "addToCartDrawer";
|
|
184
|
+
};
|
|
185
|
+
export type NavigationSourceType = (typeof NAVIGATION_SOURCE)[keyof typeof NAVIGATION_SOURCE];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { DisplayModeType } from 'enums';
|
|
1
2
|
import type { DeepPartial } from '@/interfaces/core.interface';
|
|
2
3
|
export type ProductListCardStyle = 'card' | 'ghost';
|
|
3
4
|
export type ProductListCardCornerRadius = 'rounded' | 'sharp';
|
|
4
5
|
export interface IProductListTheme {
|
|
5
6
|
backgroundColor: string;
|
|
6
7
|
}
|
|
7
|
-
export type IDisplayMode = 'modal' | 'drawer';
|
|
8
8
|
export interface IProductListLayout {
|
|
9
9
|
productCard: {
|
|
10
10
|
style: ProductListCardStyle;
|
|
@@ -19,7 +19,7 @@ export interface IProductListLayout {
|
|
|
19
19
|
showCollections: boolean;
|
|
20
20
|
enablePersonalization: boolean;
|
|
21
21
|
};
|
|
22
|
-
displayMode:
|
|
22
|
+
displayMode: DisplayModeType;
|
|
23
23
|
}
|
|
24
24
|
export interface IProductListComponent {
|
|
25
25
|
theme: IProductListTheme;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { IProductListProduct } from 'core/store/interfaces/product-list.interface';
|
|
2
|
+
import { type NavigationSourceType } from 'enums';
|
|
3
|
+
import type { IFulfillment } from 'interfaces/api/product.interface';
|
|
4
|
+
import type { IProductListComponent } from 'interfaces/configs';
|
|
1
5
|
import { BaseComponent } from '@/core/base-component.service';
|
|
2
6
|
import type { IAddressComponent } from '@/interfaces/configs';
|
|
3
7
|
import type { IAddressOptions } from './address.interface';
|
|
@@ -5,6 +9,12 @@ export interface IAddressInputComponentParams {
|
|
|
5
9
|
productId?: string;
|
|
6
10
|
isIndependentComponent?: boolean;
|
|
7
11
|
options?: IAddressOptions;
|
|
12
|
+
navigationSource?: NavigationSourceType;
|
|
13
|
+
product?: IProductListProduct;
|
|
14
|
+
shippingFulfillment?: IFulfillment | null;
|
|
15
|
+
onDemandFulfillment?: IFulfillment | null;
|
|
16
|
+
showCollections?: boolean;
|
|
17
|
+
config?: IProductListComponent;
|
|
8
18
|
}
|
|
9
19
|
export declare class AddressInputComponent extends BaseComponent<IAddressInputComponentParams, IAddressComponent> {
|
|
10
20
|
private suggestions;
|
|
@@ -24,6 +34,7 @@ export declare class AddressInputComponent extends BaseComponent<IAddressInputCo
|
|
|
24
34
|
private closeDrawer;
|
|
25
35
|
private handleCancel;
|
|
26
36
|
private handleCheckAvailability;
|
|
37
|
+
private reopenAddToCartDrawer;
|
|
27
38
|
private handleSuggestionClick;
|
|
28
39
|
private handleDocumentClick;
|
|
29
40
|
private searchAddresses;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './product-badge';
|
|
1
2
|
export * from './product-button';
|
|
2
3
|
export * from './product-fulfillments';
|
|
4
|
+
export * from './product-price-and-personalization';
|
|
3
5
|
export * from './product-quantity-selector';
|
|
4
6
|
export * from './product-sizes-list';
|
|
7
|
+
export * from './product-title';
|
package/dist/types/modules/product-list/components/card-components/product-fulfillments.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { IProductFulfillmentStore } from 'core/store/interfaces/product.interface';
|
|
2
|
+
import { type NavigationSourceType } from 'enums';
|
|
2
3
|
export interface IFulfillmentSectionParams {
|
|
3
4
|
shippingVariants: Record<string, IProductFulfillmentStore>;
|
|
4
5
|
onDemandVariants: Record<string, IProductFulfillmentStore>;
|
|
5
6
|
enableShippingFulfillment: boolean;
|
|
6
7
|
enableOnDemandFulfillment: boolean;
|
|
7
8
|
productId: string;
|
|
9
|
+
navigationSource?: NavigationSourceType;
|
|
8
10
|
onDeliveryOptionsClick: (productId: string) => void | Promise<void>;
|
|
9
11
|
}
|
|
10
12
|
export declare const createFulfillmentSection: (params: IFulfillmentSectionParams) => HTMLElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IPricePersonalizationSectionParams {
|
|
2
|
+
price: number;
|
|
3
|
+
showPrice: boolean;
|
|
4
|
+
hasPersonalization: boolean;
|
|
5
|
+
showPersonalization: boolean;
|
|
6
|
+
hasAddress: boolean;
|
|
7
|
+
wrapperClassName?: string;
|
|
8
|
+
priceClassName?: string;
|
|
9
|
+
personalizeClassName?: string;
|
|
10
|
+
personalizeText?: string;
|
|
11
|
+
onPersonalizeClick?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const createPricePersonalizationSection: ({ price, showPrice, hasPersonalization, showPersonalization, hasAddress, wrapperClassName, priceClassName, personalizeClassName, personalizeText, onPersonalizeClick, }: IPricePersonalizationSectionParams) => HTMLElement | null;
|
|
@@ -4,5 +4,6 @@ export * from './filter-components/product-list-apply-filter-button';
|
|
|
4
4
|
export * from './product-list-card-loading.component';
|
|
5
5
|
export * from './product-list-engraving.component';
|
|
6
6
|
export * from './product-list-filters.component';
|
|
7
|
+
export * from './product-list-product-pre-cart.component';
|
|
7
8
|
export * from './product-list-retailers.component';
|
|
8
9
|
export * from './product-list-search.component';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseComponent } from 'core/base-component.service';
|
|
2
2
|
import type { IEngravingFormComponentParams } from 'modules/ui-components/engraving';
|
|
3
3
|
export declare class ProductListEngravingComponent extends BaseComponent<IEngravingFormComponentParams> {
|
|
4
|
-
protected template(): HTMLElement;
|
|
4
|
+
protected template(): HTMLElement[];
|
|
5
5
|
private createHeader;
|
|
6
|
+
private handleClose;
|
|
7
|
+
private handleEngravingComplete;
|
|
8
|
+
private handleEngravingCancel;
|
|
9
|
+
private reopenAddToCartDrawer;
|
|
6
10
|
}
|
package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseComponent } from 'core/base-component.service';
|
|
2
|
+
import type { IProductListProduct } from 'core/store/interfaces/product-list.interface';
|
|
3
|
+
import { type DisplayModeType } from 'enums';
|
|
4
|
+
import type { IFulfillment } from 'interfaces/api/product.interface';
|
|
5
|
+
import type { IProductListComponent } from 'interfaces/configs';
|
|
6
|
+
export interface IProductListProductPreCartComponentParams {
|
|
7
|
+
displayMode: DisplayModeType;
|
|
8
|
+
product: IProductListProduct;
|
|
9
|
+
shippingFulfillment: IFulfillment | null;
|
|
10
|
+
onDemandFulfillment: IFulfillment | null;
|
|
11
|
+
config: IProductListComponent;
|
|
12
|
+
}
|
|
13
|
+
export declare class ProductListProductPreCartComponent extends BaseComponent<IProductListProductPreCartComponentParams, IProductListComponent> {
|
|
14
|
+
private selectedSize;
|
|
15
|
+
constructor();
|
|
16
|
+
protected template(): HTMLElement[];
|
|
17
|
+
private createCartHeader;
|
|
18
|
+
private createImageSection;
|
|
19
|
+
private createPricePersonalizationSection;
|
|
20
|
+
private createDeliversToSection;
|
|
21
|
+
private createSizesSection;
|
|
22
|
+
private handleDeliveryOptionsClick;
|
|
23
|
+
private createFulfillmentSectionWrapper;
|
|
24
|
+
createFulfillmentTextSection(selectedFulfillmentType: string, selectedFulfillmentRetailerName: string): HTMLElement;
|
|
25
|
+
private createAddToCartSection;
|
|
26
|
+
private handleAddToCart;
|
|
27
|
+
private createExpectationArrivalInfoSection;
|
|
28
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IProductListProduct } from 'core/store/interfaces/product-list.interface';
|
|
2
|
+
import { type DisplayModeType, type NavigationSourceType } from 'enums';
|
|
3
|
+
import type { IFulfillment } from 'interfaces/api/product.interface';
|
|
4
|
+
import type { IProductListComponent } from 'interfaces/configs';
|
|
2
5
|
import { BaseComponent } from '@/core/base-component.service';
|
|
3
6
|
export interface IProductListRetailersParams {
|
|
7
|
+
product?: IProductListProduct;
|
|
4
8
|
productId: string;
|
|
5
9
|
config?: IProductListComponent;
|
|
6
|
-
displayMode?:
|
|
10
|
+
displayMode?: DisplayModeType;
|
|
11
|
+
navigationSource?: NavigationSourceType;
|
|
12
|
+
shippingFulfillment?: IFulfillment | null;
|
|
13
|
+
onDemandFulfillment?: IFulfillment | null;
|
|
7
14
|
}
|
|
8
15
|
export declare class ProductListRetailersComponent extends BaseComponent<IProductListRetailersParams, IProductListComponent> {
|
|
9
16
|
get hostClasses(): string[];
|
|
@@ -13,6 +20,7 @@ export declare class ProductListRetailersComponent extends BaseComponent<IProduc
|
|
|
13
20
|
private extractFulfillments;
|
|
14
21
|
private onFulfillmentTabClick;
|
|
15
22
|
private onRetailerCardClick;
|
|
23
|
+
private reopenAddToCartDrawer;
|
|
16
24
|
private createHeader;
|
|
17
25
|
private createNoAvailabilityMessage;
|
|
18
26
|
}
|
|
@@ -16,16 +16,11 @@ export declare class ProductListCardComponent extends BaseComponent<IProductList
|
|
|
16
16
|
protected connected(): Promise<void>;
|
|
17
17
|
disconnected(): void;
|
|
18
18
|
private reRender;
|
|
19
|
-
private getAvailabilityData;
|
|
20
|
-
private isPresaleActive;
|
|
21
|
-
private handleAddToCart;
|
|
22
19
|
protected template(): HTMLElement[];
|
|
23
20
|
private generateProductUrl;
|
|
24
21
|
private createVariantStandard;
|
|
25
22
|
private createImageSection;
|
|
26
23
|
private createContentSection;
|
|
27
|
-
private createBadgesSection;
|
|
28
|
-
private createTitleSection;
|
|
29
24
|
private createPricePersonalizationSection;
|
|
30
25
|
private createSizesSection;
|
|
31
26
|
private handleDeliveryOptionsClick;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { IModalContentConfig } from 'core/store/interfaces/core.interface';
|
|
2
|
+
import type { IProductSizeStore } from 'core/store/interfaces/product.interface';
|
|
2
3
|
import type { IProductListProduct, IProductListStore } from 'core/store/interfaces/product-list.interface';
|
|
3
4
|
import { BaseCommand } from '@/core/command/base-command.service';
|
|
4
5
|
import { type FulfillmentType } from '@/enums';
|
|
5
|
-
import type { IProduct, IRetailer } from '@/interfaces/api/product.interface';
|
|
6
|
+
import type { IFulfillment, IProduct, IProductSizeAttributes, IRetailer } from '@/interfaces/api/product.interface';
|
|
6
7
|
import type { IFilterSchema, INavigationResponse, IProductSearchParams, IProductSearchResponse } from '@/interfaces/api/product-list.interface';
|
|
7
8
|
import type { ProductListFilterType } from '@/interfaces/core.interface';
|
|
8
9
|
import { type AddItemParams } from '@/modules/cart/cart.commands';
|
|
9
|
-
import type { IExtendedFilterSchema, IPagination, IProductListFilters } from './product-list.interface';
|
|
10
|
+
import type { IExtendedFilterSchema, IPagination, IProductAvailabilityData, IProductListFilters } from './product-list.interface';
|
|
10
11
|
type StateListener = (state: IProductListStore) => void;
|
|
11
12
|
export declare class ProductListCommands extends BaseCommand {
|
|
12
13
|
private readonly uiCommands;
|
|
@@ -63,5 +64,13 @@ export declare class ProductListCommands extends BaseCommand {
|
|
|
63
64
|
selectSize: (productId: string, sizeId: string) => Promise<void>;
|
|
64
65
|
private getFulfillmentForSize;
|
|
65
66
|
updateQuantity: (productId: string, quantity: number) => void;
|
|
67
|
+
getAvailabilityData(params: {
|
|
68
|
+
product: IProductListProduct;
|
|
69
|
+
size?: IProductSizeStore;
|
|
70
|
+
shippingFulfillment?: IFulfillment | null;
|
|
71
|
+
onDemandFulfillment?: IFulfillment | null;
|
|
72
|
+
state?: string;
|
|
73
|
+
}): IProductAvailabilityData;
|
|
74
|
+
isPresaleActive(sizeAttributes: IProductSizeAttributes): boolean;
|
|
66
75
|
}
|
|
67
76
|
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { IProductListProduct } from 'core/store/interfaces/product-list.interface';
|
|
2
|
+
import type { IFulfillment } from 'interfaces/api/product.interface';
|
|
1
3
|
import { BaseComponent } from '@/core/base-component.service';
|
|
2
|
-
import type
|
|
4
|
+
import { type DisplayModeType, type NavigationSourceType } from '@/enums';
|
|
5
|
+
import type { IProductListComponent } from '@/interfaces/configs';
|
|
3
6
|
export interface IEngravingFormComponentParams {
|
|
4
7
|
identifier: string;
|
|
5
8
|
context: 'product' | 'cart' | 'product-list';
|
|
@@ -8,7 +11,13 @@ export interface IEngravingFormComponentParams {
|
|
|
8
11
|
maxCharsPerLine: number;
|
|
9
12
|
fee: number;
|
|
10
13
|
location?: string;
|
|
11
|
-
displayMode?:
|
|
14
|
+
displayMode?: DisplayModeType;
|
|
15
|
+
navigationSource?: NavigationSourceType;
|
|
16
|
+
product?: IProductListProduct;
|
|
17
|
+
shippingFulfillment?: IFulfillment | null;
|
|
18
|
+
onDemandFulfillment?: IFulfillment | null;
|
|
19
|
+
showCollections?: boolean;
|
|
20
|
+
config?: IProductListComponent;
|
|
12
21
|
}
|
|
13
22
|
export declare class EngravingFormComponent extends BaseComponent<IEngravingFormComponentParams, null> {
|
|
14
23
|
get hostClasses(): string[];
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Actions
|
|
2
|
+
|
|
3
|
+
Actions let you control Elements programmatically after the SDK initializes. All actions live under `window.elements.actions.*`.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
```js
|
|
7
|
+
window.addEventListener('lce:actions.client_ready', () => {
|
|
8
|
+
window.elements.actions.cart.openCart();
|
|
9
|
+
});
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Product actions
|
|
13
|
+
- `actions.product.getDetails(identifier)`
|
|
14
|
+
Returns the current loaded product data (price, size, fulfillment, retailer, quantity, images, etc.). The product must already be injected and loaded.
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const product = window.elements.actions.product.getDetails('00619947000020');
|
|
18
|
+
console.log(product.name, product.price);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Cart actions
|
|
22
|
+
- `actions.cart.openCart()`
|
|
23
|
+
Opens the cart drawer.
|
|
24
|
+
- `actions.cart.closeCart()`
|
|
25
|
+
Closes the cart drawer.
|
|
26
|
+
- `actions.cart.toggleCart()`
|
|
27
|
+
Toggles the cart drawer open/closed.
|
|
28
|
+
- `actions.cart.addProduct(params[], openCart?)`
|
|
29
|
+
Adds one or more products to the cart. If no address is set, the SDK prompts for one and retries automatically.
|
|
30
|
+
- `actions.cart.applyPromoCode(promoCode)`
|
|
31
|
+
Applies a promo code (replaces any existing code).
|
|
32
|
+
- `actions.cart.removePromoCode()`
|
|
33
|
+
Removes the active promo code.
|
|
34
|
+
- `actions.cart.resetCart()`
|
|
35
|
+
Clears all cart items (no undo).
|
|
36
|
+
- `actions.cart.getDetails()`
|
|
37
|
+
Returns current cart data (items, totals, promo, retailers, etc.).
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
await window.elements.actions.cart.addProduct([
|
|
41
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
42
|
+
], true);
|
|
43
|
+
|
|
44
|
+
await window.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
45
|
+
await window.elements.actions.cart.removePromoCode();
|
|
46
|
+
await window.elements.actions.cart.resetCart();
|
|
47
|
+
|
|
48
|
+
const cart = window.elements.actions.cart.getDetails();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Checkout actions
|
|
52
|
+
- `actions.checkout.openCheckout()`
|
|
53
|
+
Opens the checkout drawer.
|
|
54
|
+
- `actions.checkout.closeCheckout()`
|
|
55
|
+
Closes the checkout drawer.
|
|
56
|
+
- `actions.checkout.toggleCheckout()`
|
|
57
|
+
Toggles the checkout drawer open/closed.
|
|
58
|
+
- `actions.checkout.exitCheckout()`
|
|
59
|
+
Navigates away from checkout (requires `exitUrl` config).
|
|
60
|
+
- `actions.checkout.addProduct(params[], openCheckout?)`
|
|
61
|
+
Adds products directly to checkout (bypasses cart).
|
|
62
|
+
- `actions.checkout.applyPromoCode(promoCode)`
|
|
63
|
+
Applies a promo code in checkout.
|
|
64
|
+
- `actions.checkout.removePromoCode()`
|
|
65
|
+
Removes the active promo code.
|
|
66
|
+
- `actions.checkout.applyGiftCard(code)`
|
|
67
|
+
Applies a gift card.
|
|
68
|
+
- `actions.checkout.removeGiftCard(code)`
|
|
69
|
+
Removes a gift card.
|
|
70
|
+
- `actions.checkout.toggleIsGift(active?)`
|
|
71
|
+
Enables/disables gift mode (or toggles when omitted).
|
|
72
|
+
- `actions.checkout.toggleBillingSameAsShipping(active?)`
|
|
73
|
+
Sets billing address to match shipping.
|
|
74
|
+
- `actions.checkout.toggleMarketingPreferences(field, active)`
|
|
75
|
+
Sets marketing opt-in (`canEmail` or `canSms`).
|
|
76
|
+
- `actions.checkout.updateCustomerInfo(fields)`
|
|
77
|
+
Prefills customer info (name, email, phone, birthdate, etc.).
|
|
78
|
+
- `actions.checkout.updateBillingInfo(fields)`
|
|
79
|
+
Prefills billing address fields.
|
|
80
|
+
- `actions.checkout.updateGiftInfo(fields)`
|
|
81
|
+
Prefills gift recipient information.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
window.elements.actions.checkout.openCheckout();
|
|
85
|
+
window.elements.actions.checkout.closeCheckout();
|
|
86
|
+
window.elements.actions.checkout.toggleCheckout();
|
|
87
|
+
|
|
88
|
+
await window.elements.actions.checkout.addProduct([
|
|
89
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
90
|
+
], true);
|
|
91
|
+
|
|
92
|
+
await window.elements.actions.checkout.applyPromoCode('WELCOME10');
|
|
93
|
+
await window.elements.actions.checkout.applyGiftCard('GIFT-1234-5678');
|
|
94
|
+
|
|
95
|
+
await window.elements.actions.checkout.toggleIsGift(true);
|
|
96
|
+
await window.elements.actions.checkout.toggleBillingSameAsShipping(false);
|
|
97
|
+
await window.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
|
|
98
|
+
|
|
99
|
+
window.elements.actions.checkout.updateCustomerInfo({
|
|
100
|
+
firstName: 'John',
|
|
101
|
+
lastName: 'Doe',
|
|
102
|
+
email: 'john@example.com'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
window.elements.actions.checkout.updateBillingInfo({
|
|
106
|
+
firstName: 'John',
|
|
107
|
+
lastName: 'Doe',
|
|
108
|
+
addressOne: '789 Elm St',
|
|
109
|
+
city: 'Chicago',
|
|
110
|
+
state: 'IL',
|
|
111
|
+
zipCode: '60601'
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
window.elements.actions.checkout.updateGiftInfo({
|
|
115
|
+
firstName: 'Jane',
|
|
116
|
+
lastName: 'Smith',
|
|
117
|
+
message: 'Happy Birthday!'
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Address actions
|
|
122
|
+
- `actions.address.setAddressByPlacesId(placesId)`
|
|
123
|
+
Sets address using a Google Places ID (recommended).
|
|
124
|
+
- `actions.address.setAddressManually(address, coordinates)`
|
|
125
|
+
Sets address with your own address + lat/long data.
|
|
126
|
+
- `actions.address.getDetails()`
|
|
127
|
+
Returns the current address (or null if not set).
|
|
128
|
+
- `actions.address.clear()`
|
|
129
|
+
Removes the stored address and resets availability.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
await window.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
|
|
133
|
+
|
|
134
|
+
await window.elements.actions.address.setAddressManually(
|
|
135
|
+
{ one: '123 Main Street', city: 'New York', state: 'NY', zip: '10001' },
|
|
136
|
+
{ latitude: 40.7128, longitude: -74.0060 }
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const address = window.elements.actions.address.getDetails();
|
|
140
|
+
await window.elements.actions.address.clear();
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## UI helpers (non-actions)
|
|
144
|
+
These helpers live under `window.elements.ui.*` and are commonly used with actions.
|
|
145
|
+
|
|
146
|
+
- `ui.cartButton(containerId, showItemsCount?)`
|
|
147
|
+
Renders a cart button inside the given container.
|
|
148
|
+
- `ui.floatingCartButton(showItemsCount?)`
|
|
149
|
+
Renders a floating cart button (bottom-right).
|
|
150
|
+
- `ui.cartSubtotal(elementId)`
|
|
151
|
+
Keeps an element updated with cart subtotal.
|
|
152
|
+
- `ui.cartItemsCount(elementId, { hideZero })`
|
|
153
|
+
Keeps an element updated with cart item count.
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
window.elements.ui.cartButton('header-cart', true);
|
|
157
|
+
window.elements.ui.floatingCartButton(true);
|
|
158
|
+
window.elements.ui.cartSubtotal('cart-total');
|
|
159
|
+
window.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
160
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Address
|
|
2
|
+
|
|
3
|
+
The Address component sets the delivery location used for availability, pricing, and fulfillment options.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
- Address is embedded in the Product component by default
|
|
7
|
+
- If a user adds to cart without an address, the SDK prompts automatically
|
|
8
|
+
- The address is reused across product, cart, and checkout
|
|
9
|
+
|
|
10
|
+
## Standalone address component
|
|
11
|
+
```js
|
|
12
|
+
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
13
|
+
await client.injectAddressElement('address', {
|
|
14
|
+
onAddressSet: (address) => {
|
|
15
|
+
console.log('Address set:', address);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Address actions
|
|
21
|
+
```js
|
|
22
|
+
await window.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
|
|
23
|
+
|
|
24
|
+
await window.elements.actions.address.setAddressManually(
|
|
25
|
+
{
|
|
26
|
+
one: '123 Main Street',
|
|
27
|
+
two: 'Apt 4',
|
|
28
|
+
city: 'New York',
|
|
29
|
+
state: 'NY',
|
|
30
|
+
zip: '10001'
|
|
31
|
+
},
|
|
32
|
+
{ latitude: 40.7128, longitude: -74.0060 }
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const address = window.elements.actions.address.getDetails();
|
|
36
|
+
await window.elements.actions.address.clear();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Address events (examples)
|
|
40
|
+
```js
|
|
41
|
+
window.addEventListener('lce:actions.address_updated', (event) => {
|
|
42
|
+
const { formattedAddress } = event.detail.data;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
window.addEventListener('lce:actions.address_failed', (event) => {
|
|
46
|
+
const { error } = event.detail.data;
|
|
47
|
+
});
|
|
48
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Cart
|
|
2
|
+
|
|
3
|
+
The Cart component is a slide-out drawer that manages items, quantities, promo codes, and checkout.
|
|
4
|
+
|
|
5
|
+
## What you get
|
|
6
|
+
- Drawer UI with item list and totals
|
|
7
|
+
- Grouped items by retailer
|
|
8
|
+
- Quantity updates and removals
|
|
9
|
+
- Promo code support
|
|
10
|
+
- Cart persistence across sessions and tabs
|
|
11
|
+
- Checkout entry point
|
|
12
|
+
|
|
13
|
+
## Show a cart button (CDN)
|
|
14
|
+
```html
|
|
15
|
+
<script
|
|
16
|
+
defer
|
|
17
|
+
data-liquid-commerce-elements
|
|
18
|
+
data-token="YOUR_API_KEY"
|
|
19
|
+
data-env="production"
|
|
20
|
+
data-cart-badge-button="header-cart"
|
|
21
|
+
type="text/javascript"
|
|
22
|
+
src="https://assets-elements.liquidcommerce.us/all/elements.js"
|
|
23
|
+
></script>
|
|
24
|
+
|
|
25
|
+
<div id="header-cart"></div>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Cart UI helpers (programmatic)
|
|
29
|
+
```js
|
|
30
|
+
window.elements.ui.cartButton('header-cart', true);
|
|
31
|
+
window.elements.ui.floatingCartButton(true);
|
|
32
|
+
window.elements.ui.cartSubtotal('cart-total');
|
|
33
|
+
window.elements.ui.cartItemsCount('items-count', { hideZero: true });
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Cart actions
|
|
37
|
+
```js
|
|
38
|
+
window.elements.actions.cart.openCart();
|
|
39
|
+
window.elements.actions.cart.closeCart();
|
|
40
|
+
window.elements.actions.cart.toggleCart();
|
|
41
|
+
|
|
42
|
+
await window.elements.actions.cart.addProduct([
|
|
43
|
+
{ identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
|
|
44
|
+
], true);
|
|
45
|
+
|
|
46
|
+
await window.elements.actions.cart.applyPromoCode('SUMMER20');
|
|
47
|
+
await window.elements.actions.cart.removePromoCode();
|
|
48
|
+
await window.elements.actions.cart.resetCart();
|
|
49
|
+
|
|
50
|
+
const cart = window.elements.actions.cart.getDetails();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Address behavior
|
|
54
|
+
If no address is set, add-to-cart automatically opens the address prompt, then retries the add.
|
|
55
|
+
|
|
56
|
+
## Cart events (examples)
|
|
57
|
+
```js
|
|
58
|
+
window.addEventListener('lce:actions.cart_item_added', (event) => {
|
|
59
|
+
const { identifiers, itemsAdded } = event.detail.data;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
window.addEventListener('lce:actions.cart_updated', (event) => {
|
|
63
|
+
const { subtotal, itemsCount } = event.detail.data;
|
|
64
|
+
});
|
|
65
|
+
```
|