@liquidcommerce/elements-sdk 2.2.0-beta.30 → 2.2.0-beta.32

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.
@@ -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 +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[];
@@ -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;
@@ -34,17 +34,22 @@ export interface IBuilderInjectElementParams {
34
34
  containerId: string;
35
35
  [key: string]: any;
36
36
  }
37
+ export interface IInjectedComponent {
38
+ getType(): ComponentType;
39
+ getElement(): HTMLElement;
40
+ rerender(): void;
41
+ }
37
42
  export interface ILiquidCommerceElementsBuilderMethod {
38
43
  updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
39
44
  updateProductComponent(configs: UpdateProductComponent): Promise<void>;
40
45
  updateAddressComponent(configs: UpdateAddressComponent): void;
41
46
  updateCartComponent(configs: UpdateCartComponent): void;
42
47
  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>;
48
+ injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
49
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
50
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
51
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
52
+ injectCheckoutElement(containerId: string): Promise<IInjectedComponent | null>;
48
53
  }
49
54
  export interface IProcessInjectElementParams {
50
55
  type: ComponentType;
@@ -66,11 +71,12 @@ export interface ILiquidCommerceElementsActions {
66
71
  }
67
72
  export interface ILiquidCommerceElementsClient {
68
73
  builder: ILiquidCommerceElementsBuilderMethod;
69
- injectProductElement(params: IInjectProductElement[]): Promise<void>;
70
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<void>;
71
- injectCartElement(containerId: string): Promise<void>;
72
- injectCheckoutElement(containerId: string): Promise<void>;
74
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
75
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
76
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
77
+ injectCheckoutElement(containerId: string): Promise<IInjectedComponent | null>;
73
78
  ui: ILiquidCommerceElementsUIMethod;
74
79
  actions: ILiquidCommerceElementsActions;
80
+ getInjectedComponents(): Map<string, IInjectedComponent>;
75
81
  }
76
82
  export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
@@ -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
- **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.
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
@@ -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.2.0-beta.30",
6
+ "version": "2.2.0-beta.32",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",