@liquidcommerce/elements-sdk 2.4.1 → 2.4.3
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 +82 -19
- package/dist/index.esm.js +10372 -9768
- package/dist/types/core/client/client-action.service.d.ts +1 -0
- package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +2 -0
- package/dist/types/core/pubsub/pubsub.service.d.ts +2 -1
- package/dist/types/core/singleton-manager.service.d.ts +3 -3
- package/dist/types/core/store/store.service.d.ts +0 -1
- package/dist/types/elements-base-client.d.ts +49 -0
- package/dist/types/elements-builder-client.d.ts +2 -0
- package/dist/types/elements-client-helper.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.umd.d.ts +2 -2
- package/dist/types/interfaces/configs/checkout.interface.d.ts +1 -1
- package/dist/types/interfaces/core.interface.d.ts +32 -17
- package/dist/types/modules/cart/components/index.d.ts +2 -0
- package/dist/types/modules/theme-provider/services/font-manager.service.d.ts +1 -0
- package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -0
- package/docs/ACTIONS.md +37 -1
- package/docs/CONFIGURATION.md +137 -10
- package/docs/TROUBLESHOOTING.md +18 -1
- package/package.json +5 -5
- package/umd/elements.js +1 -1
|
@@ -32,6 +32,7 @@ export interface ICheckoutActions {
|
|
|
32
32
|
closeCheckout: () => void;
|
|
33
33
|
toggleCheckout: () => void;
|
|
34
34
|
addProduct: (params: IAddProductParams[], openCheckout?: boolean) => Promise<void>;
|
|
35
|
+
addPresaleProduct: (params: IAddProductParams) => Promise<void>;
|
|
35
36
|
applyPromoCode: (promoCode: string) => Promise<void>;
|
|
36
37
|
removePromoCode: () => Promise<void>;
|
|
37
38
|
applyGiftCard: (code: string) => Promise<void>;
|
|
@@ -66,10 +66,12 @@ export interface ICheckoutGiftCardFailedEventData {
|
|
|
66
66
|
export interface ICheckoutProductAddEventData {
|
|
67
67
|
itemsAdded: number;
|
|
68
68
|
identifiers: string[];
|
|
69
|
+
isPresale?: boolean;
|
|
69
70
|
}
|
|
70
71
|
export interface ICheckoutProductAddFailedEventData {
|
|
71
72
|
identifiers: string[];
|
|
72
73
|
error: string;
|
|
74
|
+
isPresale?: boolean;
|
|
73
75
|
}
|
|
74
76
|
export interface ICheckoutItemEventData {
|
|
75
77
|
liquidId: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IElementsActionsEventsMap, IElementsFormsEventsMap, SpecificActionEvent, SpecificFormEvent } from '@/core/pubsub/interfaces';
|
|
2
2
|
export declare class PubSubService {
|
|
3
3
|
private readonly logger;
|
|
4
|
+
private clientReadyEvent;
|
|
4
5
|
constructor();
|
|
5
6
|
private readonly eventPrefix;
|
|
6
7
|
static getInstance(): PubSubService;
|
|
@@ -8,5 +9,5 @@ export declare class PubSubService {
|
|
|
8
9
|
publishForm<K extends SpecificFormEvent>(eventType: K, data: IElementsFormsEventsMap[K]): void;
|
|
9
10
|
private publishSpecific;
|
|
10
11
|
private dispatchNativeEvents;
|
|
11
|
-
private
|
|
12
|
+
private setupClientReadyBuffering;
|
|
12
13
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IClientConfigs } from '@/core/client/client-config.service';
|
|
2
|
-
import type { LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
|
|
2
|
+
import type { LiquidCommerceElementsBuilderClientConstructor, LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
|
|
3
3
|
export declare class SingletonManager {
|
|
4
4
|
private static instances;
|
|
5
5
|
private static clientConstructor;
|
|
6
6
|
private static getInstances;
|
|
7
7
|
private constructor();
|
|
8
|
-
static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor): void;
|
|
9
|
-
static getClientConstructor(): LiquidCommerceElementsClientConstructor | null;
|
|
8
|
+
static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor): void;
|
|
9
|
+
static getClientConstructor(): LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor | null;
|
|
10
10
|
static getClassInstance<T>(className: string, instanceCreator: () => T): T;
|
|
11
11
|
static getClient<T>(clientConfigs: IClientConfigs): Promise<T>;
|
|
12
12
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AuthService } from '@/core/auth.service';
|
|
2
|
+
import { ClientActionService } from '@/core/client/client-action.service';
|
|
3
|
+
import { ClientConfigService, type IClientConfigs } from '@/core/client/client-config.service';
|
|
4
|
+
import { CommandService } from '@/core/command/command.service';
|
|
5
|
+
import { DebugPanelService } from '@/core/debug-panel/debug-panel.service';
|
|
6
|
+
import { FingerPrintService } from '@/core/fingerprint.service';
|
|
7
|
+
import { GoogleTagManagerService } from '@/core/google-tag-manager.service';
|
|
8
|
+
import { LoggerFactory } from '@/core/logger/logger-factory';
|
|
9
|
+
import { StoreService } from '@/core/store';
|
|
10
|
+
import { TelemetryService } from '@/core/telemetry/telemetry.service';
|
|
11
|
+
import { type ComponentType } from '@/enums';
|
|
12
|
+
import type { IInjectedComponent, ILiquidCommerceElementsActions, IProcessInjectElementParams } from '@/interfaces/core.interface';
|
|
13
|
+
import { ApiClientService } from '@/modules/api-client';
|
|
14
|
+
import { ThemeProviderService } from '@/modules/theme-provider';
|
|
15
|
+
export declare abstract class ElementsBaseClient {
|
|
16
|
+
protected readonly authService: AuthService;
|
|
17
|
+
protected readonly clientConfig: ClientConfigService;
|
|
18
|
+
protected readonly store: StoreService;
|
|
19
|
+
protected readonly commands: CommandService;
|
|
20
|
+
protected readonly apiClient: ApiClientService;
|
|
21
|
+
protected readonly themeProvider: ThemeProviderService;
|
|
22
|
+
protected readonly fingerPrintService: FingerPrintService;
|
|
23
|
+
protected readonly googleTagManager: GoogleTagManagerService;
|
|
24
|
+
protected readonly clientAction: ClientActionService;
|
|
25
|
+
protected readonly telemetry: TelemetryService;
|
|
26
|
+
protected readonly debugPanel: DebugPanelService;
|
|
27
|
+
protected readonly logger: ReturnType<typeof LoggerFactory.get>;
|
|
28
|
+
protected clientPrepared: boolean;
|
|
29
|
+
protected componentFactoryInitialized: boolean;
|
|
30
|
+
protected cartDrawerCreated: boolean;
|
|
31
|
+
protected gtmInitialized: boolean;
|
|
32
|
+
protected injectedComponents: Map<string, IInjectedComponent>;
|
|
33
|
+
constructor(clientConfigs: IClientConfigs);
|
|
34
|
+
prepare(): Promise<void>;
|
|
35
|
+
private prepareEssentialServices;
|
|
36
|
+
private deferHeavyInitialization;
|
|
37
|
+
private initializeHeavyServices;
|
|
38
|
+
get actions(): ILiquidCommerceElementsActions;
|
|
39
|
+
protected processInjectElement(params: IProcessInjectElementParams): Promise<IInjectedComponent | null>;
|
|
40
|
+
protected ensureCartDrawerExists(): void;
|
|
41
|
+
protected ensureAllComponentsRegistered(): void;
|
|
42
|
+
protected createInjectedComponentWrapper(containerId: string, type: ComponentType, element: HTMLElement): IInjectedComponent;
|
|
43
|
+
protected rerenderInjectedComponentsByType(type: ComponentType): void;
|
|
44
|
+
protected isElementsEnabled(): boolean;
|
|
45
|
+
protected injectDisabledElementsError(containerId: string, componentName: ComponentType): void;
|
|
46
|
+
private registerEssentialComponents;
|
|
47
|
+
protected registerComponents(): void;
|
|
48
|
+
protected registerAllComponents(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { ILiquidCommerceElementsBuilderClient, ILiquidCommerceElementsBuilderConfig } from '@/interfaces/core.interface';
|
|
2
|
+
export declare function ElementsBuilder(apiKey: string, config: ILiquidCommerceElementsBuilderConfig): Promise<ILiquidCommerceElementsBuilderClient | null>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
import { type ComponentType } from '@/enums';
|
|
1
2
|
export declare function deepMergeConfigs<T extends Record<string, any>>(target: T, source: Partial<T>): T;
|
|
3
|
+
export declare const layoutFieldToComponentTypes: Map<string, ComponentType[]>;
|
|
4
|
+
export declare function getComponentTypesForLayoutFields(parentPath: string, layoutFields: Record<string, any>): ComponentType[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Elements } from './index';
|
|
2
|
-
export { Elements };
|
|
1
|
+
import { Elements, ElementsBuilder } from './index';
|
|
2
|
+
export { Elements, ElementsBuilder };
|
|
@@ -18,6 +18,7 @@ export interface ICheckoutLayout {
|
|
|
18
18
|
drawerHeaderText: string;
|
|
19
19
|
placeOrderButtonText: string;
|
|
20
20
|
placeOrderButtonShowRequiredFields: boolean;
|
|
21
|
+
checkoutCompleted: ICheckoutCompleted;
|
|
21
22
|
}
|
|
22
23
|
export interface ICheckoutCompleted {
|
|
23
24
|
customLogo: string;
|
|
@@ -25,7 +26,6 @@ export interface ICheckoutCompleted {
|
|
|
25
26
|
}
|
|
26
27
|
export interface ICheckoutTheme {
|
|
27
28
|
backgroundColor: string;
|
|
28
|
-
checkoutCompleted: ICheckoutCompleted;
|
|
29
29
|
}
|
|
30
30
|
export interface ICheckoutComponent {
|
|
31
31
|
theme: ICheckoutTheme;
|
|
@@ -17,12 +17,17 @@ export interface IClientCustomThemeConfig {
|
|
|
17
17
|
cart?: UpdateCartComponent;
|
|
18
18
|
checkout?: UpdateCheckoutComponent;
|
|
19
19
|
}
|
|
20
|
+
export interface ILiquidCommerceElementsBuilderConfig {
|
|
21
|
+
env?: ElementsEnv;
|
|
22
|
+
promoTicker?: IPromoTicker[];
|
|
23
|
+
customTheme?: IClientCustomThemeConfig;
|
|
24
|
+
debugMode?: DebugMode;
|
|
25
|
+
}
|
|
20
26
|
export interface ILiquidCommerceElementsConfig {
|
|
21
27
|
env?: ElementsEnv;
|
|
22
28
|
promoTicker?: IPromoTicker[];
|
|
23
29
|
customTheme?: IClientCustomThemeConfig;
|
|
24
30
|
proxy?: IElementsProxyConfig;
|
|
25
|
-
isBuilder?: boolean;
|
|
26
31
|
debugMode?: DebugMode;
|
|
27
32
|
}
|
|
28
33
|
export interface IInjectProductElement {
|
|
@@ -34,17 +39,10 @@ export interface IBuilderInjectElementParams {
|
|
|
34
39
|
containerId: string;
|
|
35
40
|
[key: string]: any;
|
|
36
41
|
}
|
|
37
|
-
export interface
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
updateCartComponent(configs: UpdateCartComponent): void;
|
|
42
|
-
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
43
|
-
injectElement(params: IBuilderInjectElementParams): Promise<void>;
|
|
44
|
-
injectProductElement(params: IInjectProductElement[]): Promise<void>;
|
|
45
|
-
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<void>;
|
|
46
|
-
injectCartElement(containerId: string): Promise<void>;
|
|
47
|
-
injectCheckoutElement(containerId: string): Promise<void>;
|
|
42
|
+
export interface IInjectedComponent {
|
|
43
|
+
getType(): ComponentType;
|
|
44
|
+
getElement(): HTMLElement;
|
|
45
|
+
rerender(): void;
|
|
48
46
|
}
|
|
49
47
|
export interface IProcessInjectElementParams {
|
|
50
48
|
type: ComponentType;
|
|
@@ -64,13 +62,30 @@ export interface ILiquidCommerceElementsActions {
|
|
|
64
62
|
cart: ICartActions;
|
|
65
63
|
checkout: ICheckoutActions;
|
|
66
64
|
}
|
|
65
|
+
export interface ILiquidCommerceElementsBuilderClient {
|
|
66
|
+
updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
|
|
67
|
+
updateProductComponent(configs: UpdateProductComponent): Promise<void>;
|
|
68
|
+
updateAddressComponent(configs: UpdateAddressComponent): void;
|
|
69
|
+
updateCartComponent(configs: UpdateCartComponent): void;
|
|
70
|
+
updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
|
|
71
|
+
injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
|
|
72
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
73
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
74
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
75
|
+
injectCheckoutElement(containerId: string, options?: {
|
|
76
|
+
simulatePresale?: boolean;
|
|
77
|
+
presaleExpiresInMinutes?: number;
|
|
78
|
+
}): Promise<IInjectedComponent | null>;
|
|
79
|
+
actions: ILiquidCommerceElementsActions;
|
|
80
|
+
}
|
|
67
81
|
export interface ILiquidCommerceElementsClient {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
injectCheckoutElement(containerId: string): Promise<void>;
|
|
82
|
+
injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
|
|
83
|
+
injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
|
|
84
|
+
injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
85
|
+
injectCheckoutElement(containerId: string): Promise<IInjectedComponent | null>;
|
|
73
86
|
ui: ILiquidCommerceElementsUIMethod;
|
|
74
87
|
actions: ILiquidCommerceElementsActions;
|
|
88
|
+
getInjectedComponents(): Map<string, IInjectedComponent>;
|
|
75
89
|
}
|
|
76
90
|
export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
|
|
91
|
+
export type LiquidCommerceElementsBuilderClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsBuilderClient;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './cart-body.component';
|
|
2
2
|
export * from './cart-footer.component';
|
|
3
|
+
export * from './cart-fulfillment.component';
|
|
4
|
+
export * from './cart-fulfillment.component';
|
|
3
5
|
export * from './cart-header.component';
|
|
4
6
|
export * from './cart-item.component';
|
|
5
7
|
export * from './cart-item-quantity-price.component';
|
|
@@ -2,6 +2,7 @@ import type { IFontFamily } from '@/interfaces/configs';
|
|
|
2
2
|
export declare class FontManagerService {
|
|
3
3
|
private googleFontsUrl;
|
|
4
4
|
private defaultFontFamilies;
|
|
5
|
+
private readonly fontsLinkAttribute;
|
|
5
6
|
loadGoogleFonts(fonts: IFontFamily[], globalDisplay?: string): void;
|
|
6
7
|
updateGoogleFonts(fonts: IFontFamily[], globalDisplay?: string): void;
|
|
7
8
|
private injectGoogleFontsResourceHints;
|
|
@@ -2,8 +2,10 @@ import type { ComponentType } from '@/enums';
|
|
|
2
2
|
export declare class LceElementComponent extends HTMLElement {
|
|
3
3
|
private _initialized;
|
|
4
4
|
protected _container: ShadowRoot | null;
|
|
5
|
+
private _wrappedComponentRerender;
|
|
5
6
|
constructor();
|
|
6
7
|
initialize(contentType: ComponentType, contentElement: HTMLElement): void;
|
|
8
|
+
rerender(context?: string): void;
|
|
7
9
|
private applyBasicStyles;
|
|
8
10
|
private isCSSStyleSheetSupported;
|
|
9
11
|
private applyThemeStyles;
|
package/docs/ACTIONS.md
CHANGED
|
@@ -530,7 +530,43 @@ window.addEventListener('lce:actions.checkout_product_add_failed', function(even
|
|
|
530
530
|
});
|
|
531
531
|
```
|
|
532
532
|
|
|
533
|
-
|
|
533
|
+
#### Add Presale Product to Checkout
|
|
534
|
+
```javascript
|
|
535
|
+
// Add a single presale product directly to checkout (bypasses cart, always opens checkout drawer)
|
|
536
|
+
// The method automatically validates product availability and fulfillment options
|
|
537
|
+
await actions.checkout.addPresaleProduct({
|
|
538
|
+
identifier: 'presale-product-123',
|
|
539
|
+
fulfillmentType: 'shipping',
|
|
540
|
+
quantity: 1
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// Listen for success/failure feedback (same events as regular addProduct)
|
|
544
|
+
window.addEventListener('lce:actions.checkout_product_add_success', function(event) {
|
|
545
|
+
const { itemsAdded, identifiers, isPresale } = event.detail.data;
|
|
546
|
+
if (isPresale) {
|
|
547
|
+
console.log(`✅ Added ${itemsAdded} presale product to checkout:`, identifiers);
|
|
548
|
+
showSuccessMessage('Presale item ready for checkout!');
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
window.addEventListener('lce:actions.checkout_product_add_failed', function(event) {
|
|
553
|
+
const { identifiers, error, isPresale } = event.detail.data;
|
|
554
|
+
if (isPresale) {
|
|
555
|
+
console.log(`❌ Failed to add presale product to checkout:`, identifiers, error);
|
|
556
|
+
showErrorMessage('Could not proceed with presale checkout. Please try again.');
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
**Key Features:**
|
|
562
|
+
- **Product Availability Validation**: Automatically fetches and validates product data
|
|
563
|
+
- **Fulfillment Type Support**: Checks if the requested fulfillment type is available
|
|
564
|
+
- **Presale Verification**: Ensures the product is actually a presale item
|
|
565
|
+
- **Always Opens Checkout**: Automatically opens checkout drawer after adding presale product
|
|
566
|
+
- **Address Requirement**: Opens address input if location is not available
|
|
567
|
+
- **Error Handling**: Comprehensive error handling with detailed feedback
|
|
568
|
+
|
|
569
|
+
**Real Business Use**: Perfect for "Buy Now" buttons, one-click purchasing, express checkout flows, or any scenario where you want to skip the cart and go straight to checkout. The `addPresaleProduct` method is specifically designed for presale items that need to bypass the regular cart flow and go directly to checkout.
|
|
534
570
|
|
|
535
571
|
#### Pre-fill Customer Information
|
|
536
572
|
```javascript
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -308,34 +308,161 @@ data-env="production"
|
|
|
308
308
|
data-debug-mode="console"
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
#### `data-cart-
|
|
311
|
+
#### `data-cart-button`
|
|
312
312
|
|
|
313
313
|
**Type:** `string`
|
|
314
314
|
|
|
315
|
-
Container ID for cart button.
|
|
315
|
+
Container ID, CSS selector, or position-prefixed selector for simple cart button (no badge).
|
|
316
316
|
|
|
317
317
|
```html
|
|
318
|
-
|
|
318
|
+
<!-- Simple ID (with or without # prefix) -->
|
|
319
|
+
data-cart-button="header-cart" <!-- Works with or without # -->
|
|
320
|
+
data-cart-button="#header-cart" <!-- Also works with # prefix -->
|
|
321
|
+
|
|
322
|
+
<!-- CSS Selector (from browser inspect tool) -->
|
|
323
|
+
data-cart-button=".header .nav-links"
|
|
324
|
+
data-cart-button="#main-navigation"
|
|
325
|
+
|
|
326
|
+
<!-- Position-prefixed selectors -->
|
|
327
|
+
data-cart-button="above:.header .logo" <!-- Place above the target -->
|
|
328
|
+
data-cart-button="below:#main-navigation" <!-- Place below the target -->
|
|
329
|
+
data-cart-button="below:main-navigation" <!-- Also works without # prefix -->
|
|
330
|
+
data-cart-button="replace:.old-cart" <!-- Replace the target -->
|
|
331
|
+
data-cart-button="inside:.header .nav" <!-- Place inside the target (default) -->
|
|
319
332
|
```
|
|
320
333
|
|
|
321
|
-
#### `data-
|
|
334
|
+
#### `data-cart-badge-button`
|
|
322
335
|
|
|
323
|
-
**Type:**
|
|
336
|
+
**Type:** `string`
|
|
324
337
|
|
|
325
|
-
|
|
338
|
+
Container ID, CSS selector, or position-prefixed selector for cart button with item count badge.
|
|
326
339
|
|
|
327
340
|
```html
|
|
328
|
-
|
|
341
|
+
<!-- Simple ID (with or without # prefix) -->
|
|
342
|
+
data-cart-badge-button="header-cart" <!-- Works with or without # -->
|
|
343
|
+
data-cart-badge-button="#header-cart" <!-- Also works with # prefix -->
|
|
344
|
+
|
|
345
|
+
<!-- CSS Selector (from browser inspect tool) -->
|
|
346
|
+
data-cart-badge-button=".header .nav-links"
|
|
347
|
+
data-cart-badge-button="#main-navigation"
|
|
348
|
+
|
|
349
|
+
<!-- Position-prefixed selectors -->
|
|
350
|
+
data-cart-badge-button="above:.header .logo" <!-- Place above the target -->
|
|
351
|
+
data-cart-badge-button="below:#main-navigation" <!-- Place below the target -->
|
|
352
|
+
data-cart-badge-button="replace:.old-cart" <!-- Replace the target -->
|
|
353
|
+
data-cart-badge-button="inside:.header .nav" <!-- Place inside the target (default) -->
|
|
329
354
|
```
|
|
330
355
|
|
|
331
|
-
|
|
356
|
+
**Position Prefixes:**
|
|
357
|
+
- `above:` - Place above the target element
|
|
358
|
+
- `below:` - Place below the target element
|
|
359
|
+
- `replace:` - Replace the target element
|
|
360
|
+
- `inside:` - Place inside the target element (default)
|
|
361
|
+
|
|
362
|
+
#### `data-cart-button-hidden`
|
|
332
363
|
|
|
333
364
|
**Type:** flag (no value)
|
|
334
365
|
|
|
335
|
-
Hide
|
|
366
|
+
Hide cart button completely.
|
|
336
367
|
|
|
337
368
|
```html
|
|
338
|
-
data-
|
|
369
|
+
data-cart-button-hidden
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Cart Button Examples
|
|
373
|
+
|
|
374
|
+
**Simple cart button (no badge):**
|
|
375
|
+
```html
|
|
376
|
+
<script
|
|
377
|
+
data-liquid-commerce-elements
|
|
378
|
+
data-token="your-api-key"
|
|
379
|
+
data-cart-button="header-cart"
|
|
380
|
+
src="elements.js">
|
|
381
|
+
</script>
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Cart button with item count badge:**
|
|
385
|
+
```html
|
|
386
|
+
<script
|
|
387
|
+
data-liquid-commerce-elements
|
|
388
|
+
data-token="your-api-key"
|
|
389
|
+
data-cart-badge-button="header-cart"
|
|
390
|
+
src="elements.js">
|
|
391
|
+
</script>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Using position-prefixed selectors:**
|
|
395
|
+
```html
|
|
396
|
+
<!-- Place inside the target element (default) -->
|
|
397
|
+
<script
|
|
398
|
+
data-liquid-commerce-elements
|
|
399
|
+
data-token="your-api-key"
|
|
400
|
+
data-cart-badge-button="inside:.header .nav-links"
|
|
401
|
+
src="elements.js">
|
|
402
|
+
</script>
|
|
403
|
+
|
|
404
|
+
<!-- Place above the target element -->
|
|
405
|
+
<script
|
|
406
|
+
data-liquid-commerce-elements
|
|
407
|
+
data-token="your-api-key"
|
|
408
|
+
data-cart-button="above:.header .logo"
|
|
409
|
+
src="elements.js">
|
|
410
|
+
</script>
|
|
411
|
+
|
|
412
|
+
<!-- Place below the target element -->
|
|
413
|
+
<script
|
|
414
|
+
data-liquid-commerce-elements
|
|
415
|
+
data-token="your-api-key"
|
|
416
|
+
data-cart-badge-button="below:#main-navigation"
|
|
417
|
+
src="elements.js">
|
|
418
|
+
</script>
|
|
419
|
+
|
|
420
|
+
<!-- Replace the target element -->
|
|
421
|
+
<script
|
|
422
|
+
data-liquid-commerce-elements
|
|
423
|
+
data-token="your-api-key"
|
|
424
|
+
data-cart-button="replace:.old-cart-button"
|
|
425
|
+
src="elements.js">
|
|
426
|
+
</script>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**No cart button:**
|
|
430
|
+
```html
|
|
431
|
+
<script
|
|
432
|
+
data-liquid-commerce-elements
|
|
433
|
+
data-token="your-api-key"
|
|
434
|
+
data-cart-button-hidden
|
|
435
|
+
src="elements.js">
|
|
436
|
+
</script>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Default behavior (floating cart button with badge):**
|
|
440
|
+
```html
|
|
441
|
+
<script
|
|
442
|
+
data-liquid-commerce-elements
|
|
443
|
+
data-token="your-api-key"
|
|
444
|
+
src="elements.js">
|
|
445
|
+
</script>
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Getting CSS Selectors from Browser
|
|
449
|
+
|
|
450
|
+
**Super Easy Method:**
|
|
451
|
+
1. **Right-click** on any element where you want the cart button
|
|
452
|
+
2. Select **"Inspect"** or **"Inspect Element"**
|
|
453
|
+
3. In developer tools, **right-click** on the highlighted element
|
|
454
|
+
4. Select **"Copy" → "Copy selector"**
|
|
455
|
+
5. Paste the selector into your `data-cart-button` or `data-cart-badge-button` attribute
|
|
456
|
+
|
|
457
|
+
**Example:**
|
|
458
|
+
```html
|
|
459
|
+
<!-- After copying selector from browser inspect tool -->
|
|
460
|
+
<script
|
|
461
|
+
data-liquid-commerce-elements
|
|
462
|
+
data-token="your-api-key"
|
|
463
|
+
data-cart-badge-button="body > div.container > header > nav > div.nav-links"
|
|
464
|
+
src="elements.js">
|
|
465
|
+
</script>
|
|
339
466
|
```
|
|
340
467
|
|
|
341
468
|
### Product Configuration
|
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -102,9 +102,26 @@ console.log('Container:', container); // Should not be null
|
|
|
102
102
|
// 2. Wait for DOM
|
|
103
103
|
window.addEventListener('DOMContentLoaded', async () => {
|
|
104
104
|
const client = await Elements('YOUR_API_KEY', { env: 'production' });
|
|
105
|
-
await client.injectProductElement([
|
|
105
|
+
const components = await client.injectProductElement([
|
|
106
106
|
{ containerId: 'product-container', identifier: 'product-123' }
|
|
107
107
|
]);
|
|
108
|
+
|
|
109
|
+
// Check if injection was successful
|
|
110
|
+
if (components.length > 0) {
|
|
111
|
+
console.log('Product component injected successfully');
|
|
112
|
+
// components[0].rerender() - Rerender if needed
|
|
113
|
+
// components[0].getElement() - Get container element
|
|
114
|
+
// components[0].getType() - Get component type
|
|
115
|
+
} else {
|
|
116
|
+
console.log('Product injection failed');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Debug: Check all injected components
|
|
120
|
+
const allComponents = client.getInjectedComponents();
|
|
121
|
+
console.log('All injected components:', allComponents);
|
|
122
|
+
allComponents.forEach((component, containerId) => {
|
|
123
|
+
console.log(`Container: ${containerId}, Type: ${component.getType()}`);
|
|
124
|
+
});
|
|
108
125
|
});
|
|
109
126
|
|
|
110
127
|
// 3. Monitor product loading
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "LiquidCommerce Elements SDK",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "LiquidCommerce Team",
|
|
6
|
-
"version": "2.4.
|
|
6
|
+
"version": "2.4.3",
|
|
7
7
|
"homepage": "https://docs.liquidcommerce.co/elements-sdk",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"embeddable commerce"
|
|
72
72
|
],
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@biomejs/biome": "2.2.
|
|
74
|
+
"@biomejs/biome": "2.2.7",
|
|
75
75
|
"@commitlint/cli": "^20.1.0",
|
|
76
76
|
"@commitlint/config-conventional": "^20.0.0",
|
|
77
77
|
"@rollup/plugin-alias": "^5.1.1",
|
|
78
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
78
|
+
"@rollup/plugin-commonjs": "^28.0.9",
|
|
79
79
|
"@rollup/plugin-json": "^6.1.0",
|
|
80
80
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
81
81
|
"@rollup/plugin-replace": "^6.0.2",
|
|
@@ -87,14 +87,14 @@
|
|
|
87
87
|
"@semantic-release/npm": "^13.1.1",
|
|
88
88
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
89
89
|
"@types/core-js": "^2.5.8",
|
|
90
|
-
"@types/node": "^24.9.
|
|
90
|
+
"@types/node": "^24.9.1",
|
|
91
91
|
"conventional-changelog-cli": "^5.0.0",
|
|
92
92
|
"husky": "^9.1.7",
|
|
93
93
|
"process": "^0.11.10",
|
|
94
94
|
"rollup": "^4.52.5",
|
|
95
95
|
"rollup-obfuscator": "^4.1.1",
|
|
96
96
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
97
|
-
"semantic-release": "^
|
|
97
|
+
"semantic-release": "^25.0.1",
|
|
98
98
|
"ts-node": "^10.9.2",
|
|
99
99
|
"typescript": "^5.9.3"
|
|
100
100
|
},
|