@liquidcommerce/elements-sdk 2.7.13 → 2.7.14

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.
@@ -3,6 +3,7 @@ import { LoggerFactory } from '@/core/logger/logger-factory';
3
3
  import { PubSubService } from '@/core/pubsub/pubsub.service';
4
4
  import { StoreService } from '@/core/store/store.service';
5
5
  import type { ILocation } from '@/interfaces/api/address.interface';
6
+ import type { IProductSizeEngraving, IProductVariant } from '@/interfaces/api/product.interface';
6
7
  import { ThemeProviderService } from '@/modules/theme-provider/theme-provider.service';
7
8
  export declare abstract class BaseActionService {
8
9
  protected readonly pubSub: PubSubService;
@@ -12,4 +13,10 @@ export declare abstract class BaseActionService {
12
13
  protected readonly logger: ReturnType<typeof LoggerFactory.get>;
13
14
  constructor(loggerName: string);
14
15
  protected getLocation(): ILocation | undefined;
16
+ protected sanitizeEngravingInput(rawLines: string[] | undefined, identifier: string): string[] | undefined;
17
+ protected clampEngravingToSizeLimits(requestedLines: string[], sizeEngraving: IProductSizeEngraving | undefined, identifier: string): string[] | undefined;
18
+ protected findVariantForFulfillment(variants: (IProductVariant | undefined)[], wantsEngraving: boolean): {
19
+ variant: IProductVariant | null;
20
+ engravingDropped: boolean;
21
+ };
15
22
  }
@@ -5,6 +5,7 @@ export interface IAddProductParams {
5
5
  identifier: string;
6
6
  fulfillmentType: FulfillmentType;
7
7
  quantity: number;
8
+ engravingLines?: string[];
8
9
  }
9
10
  export interface ICartActions {
10
11
  openCart: () => void;
@@ -13,6 +13,7 @@ export declare class ProductCommands extends BaseCommand {
13
13
  createProductInstance(productId: string, firstTime?: boolean): Promise<void>;
14
14
  loadMultipleProducts(productIds: string[]): Promise<void>;
15
15
  loadProduct(productId: string, customProductData?: IProductAvailabilityResponse | null): Promise<void>;
16
+ cacheProductFromApiData(identifier: string, apiData: IProductAvailabilityResponse): void;
16
17
  selectSize(productId: string, sizeId: string): Promise<void>;
17
18
  selectFulfillment(productId: string, selectedFulfillmentId: string): Promise<void>;
18
19
  updateQuantity(productId: string, delta: number): Promise<void>;
@@ -81,9 +81,20 @@ interface IAddProductParams {
81
81
  identifier: string; // Product UPC, SKU, or ID
82
82
  fulfillmentType: FulfillmentType; // 'shipping' or 'onDemand'
83
83
  quantity: number; // Number of items
84
+ engravingLines?: string[]; // Optional engraving (see below)
84
85
  }
85
86
  ```
86
87
 
88
+ #### `engravingLines` (optional)
89
+
90
+ Pre-fills an engraving for the added item. The SDK enforces the product's engraving rules and degrades silently rather than failing the call:
91
+
92
+ - Non-string-array input is ignored (warning logged).
93
+ - Blank/whitespace-only entries are stripped; an empty result is treated as no engraving.
94
+ - If the product/size doesn't support engraving, lines are dropped.
95
+ - Lines beyond `maxLines` are sliced off; any line longer than `maxCharsPerLine` is truncated.
96
+ - If no engravable variant is available for the chosen fulfillment, lines are dropped and the item is still added.
97
+
87
98
  ### Example
88
99
 
89
100
  ```javascript
@@ -109,6 +120,16 @@ await window.LiquidCommerce.elements.actions.cart.addProduct([
109
120
  quantity: 1
110
121
  }
111
122
  ]);
123
+
124
+ // Add a product with engraving
125
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
126
+ {
127
+ identifier: '00619947000020',
128
+ fulfillmentType: 'shipping',
129
+ quantity: 1,
130
+ engravingLines: ['Happy Birthday', 'Love, Sam']
131
+ }
132
+ ], true);
112
133
  ```
113
134
 
114
135
  ### Address Requirement
@@ -62,6 +62,8 @@ addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
62
62
 
63
63
  Add products directly to checkout, bypassing the cart.
64
64
 
65
+ `IAddProductParams.engravingLines?: string[]` — optional engraving. Same rules as [`actions.cart.addProduct()`](./cart-actions.md#actionscartaddproduct): invalid input is ignored, blanks stripped, lines clamped to the product's `maxLines` / `maxCharsPerLine`, and engraving is dropped (without failing) when the product, variant, or fulfillment doesn't support it.
66
+
65
67
  ```javascript
66
68
  await window.LiquidCommerce.elements.actions.checkout.addProduct([
67
69
  {
@@ -70,6 +72,16 @@ await window.LiquidCommerce.elements.actions.checkout.addProduct([
70
72
  quantity: 1
71
73
  }
72
74
  ], true); // Open checkout after adding
75
+
76
+ // With engraving
77
+ await window.LiquidCommerce.elements.actions.checkout.addProduct([
78
+ {
79
+ identifier: '00619947000020',
80
+ fulfillmentType: 'shipping',
81
+ quantity: 1,
82
+ engravingLines: ['For Dad']
83
+ }
84
+ ], true);
73
85
  ```
74
86
 
75
87
  ### actions.checkout.addAnonymousProduct()
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.7.13",
6
+ "version": "2.7.14",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",
@@ -78,8 +78,8 @@
78
78
  ],
79
79
  "devDependencies": {
80
80
  "@biomejs/biome": "^2.4.13",
81
- "@commitlint/cli": "^20.5.0",
82
- "@commitlint/config-conventional": "^20.5.0",
81
+ "@commitlint/cli": "^20.5.3",
82
+ "@commitlint/config-conventional": "^20.5.3",
83
83
  "@rollup/plugin-alias": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^29.0.2",
85
85
  "@rollup/plugin-json": "^6.1.0",