@liquidcommerce/elements-sdk 2.6.0-beta.9 → 2.6.0-beta.90

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.
Files changed (225) hide show
  1. package/README.md +84 -2520
  2. package/dist/index.checkout.esm.js +16940 -0
  3. package/dist/index.esm.js +24189 -20939
  4. package/dist/ssr-stub.checkout.esm.js +18 -0
  5. package/dist/ssr-stub.esm.js +270 -0
  6. package/dist/types/auto-initialize/checkout.d.ts +2 -0
  7. package/dist/types/auto-initialize/shared-utils.d.ts +50 -0
  8. package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +15 -2
  9. package/dist/types/clients/builder.d.ts +3 -0
  10. package/dist/types/clients/checkout.d.ts +6 -0
  11. package/dist/types/{elements-client-helper.d.ts → clients/helpers.d.ts} +2 -1
  12. package/dist/types/clients/main.d.ts +3 -0
  13. package/dist/types/constants/core.constant.d.ts +2 -6
  14. package/dist/types/core/api/api-client.service.d.ts +20 -18
  15. package/dist/types/core/api/api-result.d.ts +19 -0
  16. package/dist/types/core/api/auth-client.service.d.ts +37 -13
  17. package/dist/types/core/api/http-client.service.d.ts +0 -8
  18. package/dist/types/core/base-component.service.d.ts +2 -1
  19. package/dist/types/core/client/actions/base-action.service.d.ts +22 -0
  20. package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
  21. package/dist/types/core/client/actions/client-cart-action.service.d.ts +38 -0
  22. package/dist/types/core/client/actions/client-checkout-action.service.d.ts +69 -0
  23. package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
  24. package/dist/types/core/client/client-action.service.d.ts +6 -74
  25. package/dist/types/core/client/client-config.service.d.ts +8 -5
  26. package/dist/types/core/google-tag-manager.service.d.ts +2 -1
  27. package/dist/types/core/logger/logger.service.d.ts +1 -1
  28. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
  29. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +1 -1
  30. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +36 -51
  31. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +11 -6
  32. package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
  33. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  34. package/dist/types/core/store/interfaces/cart.interface.d.ts +2 -3
  35. package/dist/types/core/store/interfaces/checkout.interface.d.ts +18 -108
  36. package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
  37. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  38. package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
  39. package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
  40. package/dist/types/core/store/store.constant.d.ts +5 -0
  41. package/dist/types/core/store/store.service.d.ts +1 -0
  42. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  43. package/dist/types/enums/core.enum.d.ts +39 -1
  44. package/dist/types/enums/index.d.ts +0 -1
  45. package/dist/types/index.checkout.d.ts +8 -0
  46. package/dist/types/index.checkout.umd.d.ts +4 -0
  47. package/dist/types/index.d.ts +8 -3
  48. package/dist/types/interfaces/api/cart.interface.d.ts +12 -7
  49. package/dist/types/interfaces/api/checkout.interface.d.ts +239 -0
  50. package/dist/types/interfaces/api/index.d.ts +5 -0
  51. package/dist/types/interfaces/api/product-list.interface.d.ts +39 -0
  52. package/dist/types/interfaces/api/product.interface.d.ts +10 -4
  53. package/dist/types/interfaces/client.interface.d.ts +72 -0
  54. package/dist/types/interfaces/component.interface.d.ts +7 -0
  55. package/dist/types/interfaces/config.interface.d.ts +40 -0
  56. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  57. package/dist/types/interfaces/configs/cart.interface.d.ts +1 -1
  58. package/dist/types/interfaces/configs/checkout.interface.d.ts +2 -1
  59. package/dist/types/interfaces/configs/global.interface.d.ts +5 -3
  60. package/dist/types/interfaces/configs/index.d.ts +1 -0
  61. package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
  62. package/dist/types/interfaces/configs/product.interface.d.ts +3 -1
  63. package/dist/types/interfaces/injection.interface.d.ts +49 -0
  64. package/dist/types/modules/address/address.command.d.ts +2 -1
  65. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  66. package/dist/types/modules/cart/cart.commands.d.ts +4 -4
  67. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  68. package/dist/types/modules/checkout/checkout.commands.d.ts +26 -10
  69. package/dist/types/modules/checkout/checkout.component.d.ts +2 -0
  70. package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +2 -2
  71. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +3 -0
  72. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  73. package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +3 -0
  74. package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
  75. package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +1 -1
  76. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +14 -1
  77. package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
  78. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +2 -1
  79. package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +2 -2
  80. package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
  81. package/dist/types/modules/checkout/constant.d.ts +3 -0
  82. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  83. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +1 -0
  84. package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
  85. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +3 -0
  86. package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
  87. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +3 -0
  88. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +5 -2
  89. package/dist/types/modules/product/product.commands.d.ts +3 -3
  90. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  91. package/dist/types/modules/product-list/components/card-components/index.d.ts +5 -0
  92. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
  93. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
  94. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +13 -0
  95. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +10 -0
  96. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +13 -0
  97. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  98. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  99. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  100. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  101. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +14 -0
  102. 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} +1 -1
  103. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
  104. package/dist/types/modules/product-list/components/index.d.ts +6 -2
  105. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
  106. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +39 -31
  107. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
  108. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +55 -36
  109. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
  110. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +50 -0
  111. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
  112. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +8 -0
  113. package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
  114. package/dist/types/modules/product-list/product-list.commands.d.ts +23 -8
  115. package/dist/types/modules/product-list/product-list.component.d.ts +14 -47
  116. package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
  117. package/dist/types/modules/product-list/product-list.interface.d.ts +20 -35
  118. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  119. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  120. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  121. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  122. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  123. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  124. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  125. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  126. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
  127. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +1 -0
  128. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +6 -1
  129. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +6 -1
  130. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  131. package/dist/types/modules/ui-components/input/input.component.d.ts +8 -1
  132. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  133. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  134. package/dist/types/modules/ui-components/ui.commands.d.ts +5 -1
  135. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  136. package/dist/types/ssr/stub.d.ts +10 -0
  137. package/dist/types/static/icon/check.icon.d.ts +2 -0
  138. package/dist/types/static/icon/index.d.ts +1 -0
  139. package/dist/types/utils/dom-compat.d.ts +2 -0
  140. package/dist/types/utils/format.d.ts +0 -14
  141. package/dist/types/utils/product-selection.d.ts +16 -0
  142. package/dist/types/utils/product.d.ts +15 -0
  143. package/docs/v1/README.md +210 -0
  144. package/docs/v1/api/actions/address-actions.md +286 -0
  145. package/docs/v1/api/actions/cart-actions.md +357 -0
  146. package/docs/v1/api/actions/checkout-actions.md +525 -0
  147. package/docs/v1/api/actions/product-actions.md +204 -0
  148. package/docs/v1/api/client.md +517 -0
  149. package/docs/v1/api/configuration.md +532 -0
  150. package/docs/v1/api/injection-methods.md +292 -0
  151. package/docs/v1/api/typescript-types.md +419 -0
  152. package/docs/v1/api/ui-helpers.md +200 -0
  153. package/docs/v1/examples/advanced-patterns.md +199 -0
  154. package/docs/v1/examples/checkout-flow.md +90 -0
  155. package/docs/v1/examples/custom-theming.md +63 -0
  156. package/docs/v1/examples/multi-product-page.md +90 -0
  157. package/docs/v1/examples/simple-product-page.md +89 -0
  158. package/docs/v1/getting-started/concepts.md +502 -0
  159. package/docs/v1/getting-started/installation.md +328 -0
  160. package/docs/v1/getting-started/quick-start.md +405 -0
  161. package/docs/v1/guides/address-component.md +435 -0
  162. package/docs/v1/guides/best-practices.md +365 -0
  163. package/docs/v1/guides/cart-component.md +725 -0
  164. package/docs/v1/guides/checkout-component.md +670 -0
  165. package/docs/v1/guides/events.md +926 -0
  166. package/docs/v1/guides/product-component.md +731 -0
  167. package/docs/v1/guides/product-list-component.md +631 -0
  168. package/docs/v1/guides/theming.md +213 -0
  169. package/docs/v1/integration/angular.md +39 -0
  170. package/docs/v1/integration/laravel.md +41 -0
  171. package/docs/v1/integration/nextjs.md +69 -0
  172. package/docs/v1/integration/proxy-setup.md +106 -0
  173. package/docs/v1/integration/react.md +64 -0
  174. package/docs/v1/integration/vanilla-js.md +84 -0
  175. package/docs/v1/integration/vue.md +58 -0
  176. package/docs/v1/reference/browser-support.md +45 -0
  177. package/docs/v1/reference/error-handling.md +75 -0
  178. package/docs/v1/reference/performance.md +52 -0
  179. package/docs/v1/reference/troubleshooting.md +136 -0
  180. package/package.json +33 -37
  181. package/dist/types/elements-builder-client.d.ts +0 -2
  182. package/dist/types/elements-client.d.ts +0 -2
  183. package/dist/types/enums/cloud.enum.d.ts +0 -106
  184. package/dist/types/interfaces/cloud/catalog.interface.d.ts +0 -42
  185. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
  186. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  187. package/dist/types/interfaces/cloud/index.d.ts +0 -4
  188. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  189. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  190. package/dist/types/interfaces/core.interface.d.ts +0 -111
  191. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  192. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  193. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  194. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  195. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
  196. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  197. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  198. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  199. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  200. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  201. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  202. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  203. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  204. package/dist/types/utils/helper.d.ts +0 -28
  205. package/docs/ACTIONS.md +0 -1300
  206. package/docs/BROWSER_SUPPORT.md +0 -279
  207. package/docs/CONFIGURATION.md +0 -853
  208. package/docs/DOCUMENTATION_INDEX.md +0 -311
  209. package/docs/EVENTS.md +0 -798
  210. package/docs/PROXY.md +0 -228
  211. package/docs/THEMING.md +0 -592
  212. package/docs/TROUBLESHOOTING.md +0 -793
  213. package/umd/elements.js +0 -1
  214. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  215. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  216. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  217. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  218. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  219. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  220. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  221. /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} +0 -0
  222. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  223. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  224. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  225. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -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
+ });
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)
@@ -0,0 +1,357 @@
1
+ # Cart Actions API
2
+
3
+ Cart actions allow you to programmatically control the shopping cart.
4
+
5
+ ## actions.cart.openCart()
6
+
7
+ Open the cart drawer.
8
+
9
+ ### Signature
10
+
11
+ ```typescript
12
+ openCart(): void
13
+ ```
14
+
15
+ ### Example
16
+
17
+ ```javascript
18
+ window.LiquidCommerce.elements.actions.cart.openCart();
19
+ ```
20
+
21
+ ---
22
+
23
+ ## actions.cart.closeCart()
24
+
25
+ Close the cart drawer.
26
+
27
+ ### Signature
28
+
29
+ ```typescript
30
+ closeCart(): void
31
+ ```
32
+
33
+ ### Example
34
+
35
+ ```javascript
36
+ window.LiquidCommerce.elements.actions.cart.closeCart();
37
+ ```
38
+
39
+ ---
40
+
41
+ ## actions.cart.toggleCart()
42
+
43
+ Toggle the cart drawer open/closed.
44
+
45
+ ### Signature
46
+
47
+ ```typescript
48
+ toggleCart(): void
49
+ ```
50
+
51
+ ### Example
52
+
53
+ ```javascript
54
+ // Add to your cart button
55
+ document.getElementById('cart-btn').addEventListener('click', () => {
56
+ window.LiquidCommerce.elements.actions.cart.toggleCart();
57
+ });
58
+ ```
59
+
60
+ ---
61
+
62
+ ## actions.cart.addProduct()
63
+
64
+ Add products to the cart programmatically.
65
+
66
+ ### Signature
67
+
68
+ ```typescript
69
+ addProduct(params: IAddProductParams[], openCart?: boolean): Promise<void>
70
+ ```
71
+
72
+ ### Parameters
73
+
74
+ | Parameter | Type | Required | Description |
75
+ |-----------|------|----------|-------------|
76
+ | `params` | IAddProductParams[] | Yes | Array of products to add |
77
+ | `openCart` | boolean | No | Open cart after adding (default: false) |
78
+
79
+ ```typescript
80
+ interface IAddProductParams {
81
+ identifier: string; // Product UPC, size ID, or salsify grouping ID
82
+ fulfillmentType: FulfillmentType; // 'shipping' or 'onDemand'
83
+ quantity: number; // Number of items
84
+ engravingLines?: string[]; // Optional engraving (see below)
85
+ }
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
+
98
+ ### Example
99
+
100
+ ```javascript
101
+ // Add single product
102
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
103
+ {
104
+ identifier: '00619947000020',
105
+ fulfillmentType: 'shipping',
106
+ quantity: 1
107
+ }
108
+ ], true); // Open cart after adding
109
+
110
+ // Add multiple products
111
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
112
+ {
113
+ identifier: '00619947000020',
114
+ fulfillmentType: 'shipping',
115
+ quantity: 2
116
+ },
117
+ {
118
+ identifier: '08504405135',
119
+ fulfillmentType: 'onDemand',
120
+ quantity: 1
121
+ }
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);
133
+ ```
134
+
135
+ ### Address Requirement
136
+
137
+ If no address is set, the SDK automatically:
138
+ 1. Opens address input drawer
139
+ 2. Waits for user to set address
140
+ 3. Retries add-to-cart operation
141
+
142
+ ### Errors
143
+
144
+ **Throws `SDKError` if:**
145
+ - Identifier is invalid
146
+ - Fulfillment type is not `'shipping'` or `'onDemand'`
147
+ - Quantity is less than 1
148
+
149
+ Unavailable products and presale items are **not** thrown — they are silently skipped (a `cart.error` is set on the store). If no products could be added, a `cart_product_add_failed` event is emitted with `{ cartId, identifiers, error }` and the returned promise still resolves (it does not reject).
150
+
151
+ ---
152
+
153
+ ## actions.cart.applyPromoCode()
154
+
155
+ Apply a promo code to the cart.
156
+
157
+ ### Signature
158
+
159
+ ```typescript
160
+ applyPromoCode(promoCode: string): Promise<void>
161
+ ```
162
+
163
+ ### Parameters
164
+
165
+ | Parameter | Type | Required | Description |
166
+ |-----------|------|----------|-------------|
167
+ | `promoCode` | string | Yes | Promo code to apply |
168
+
169
+ ### Example
170
+
171
+ ```javascript
172
+ try {
173
+ await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
174
+ console.log('Promo code applied successfully');
175
+ } catch (error) {
176
+ console.error('Invalid promo code:', error);
177
+ }
178
+ ```
179
+
180
+ ### Notes
181
+
182
+ - Code is automatically normalized (trimmed, uppercased)
183
+ - Promo codes must be enabled in configuration
184
+ - Only one promo code can be active at a time
185
+ - Applying a new code replaces the existing one
186
+
187
+ ---
188
+
189
+ ## actions.cart.removePromoCode()
190
+
191
+ Remove the active promo code.
192
+
193
+ ### Signature
194
+
195
+ ```typescript
196
+ removePromoCode(): Promise<void>
197
+ ```
198
+
199
+ ### Example
200
+
201
+ ```javascript
202
+ await window.LiquidCommerce.elements.actions.cart.removePromoCode();
203
+ ```
204
+
205
+ ---
206
+
207
+ ## actions.cart.resetCart()
208
+
209
+ Clear all items from the cart.
210
+
211
+ ### Signature
212
+
213
+ ```typescript
214
+ resetCart(): Promise<void>
215
+ ```
216
+
217
+ ### Example
218
+
219
+ ```javascript
220
+ await window.LiquidCommerce.elements.actions.cart.resetCart();
221
+ console.log('Cart cleared');
222
+ ```
223
+
224
+ ### Warning
225
+
226
+ This permanently removes all cart items. There is no undo.
227
+
228
+ ---
229
+
230
+ ## actions.cart.getDetails()
231
+
232
+ Retrieve current cart information.
233
+
234
+ ### Signature
235
+
236
+ ```typescript
237
+ getDetails(): IBaseCartEventData
238
+ ```
239
+
240
+ ### Returns
241
+
242
+ ```typescript
243
+ interface IBaseCartEventData {
244
+ cartId: string;
245
+ promoCodeDiscount: number | null; // in cents
246
+ subtotal: number; // in cents
247
+ itemCount: number;
248
+ items: Record<string, ICartItem>; // keyed by item ID
249
+ retailers: Record<string, ICartRetailer>; // keyed by retailer ID
250
+ location: {
251
+ placesId: string;
252
+ formattedAddress: string;
253
+ address: IAddressAddress;
254
+ coordinates: IAddressCoordinates;
255
+ } | null;
256
+ }
257
+ ```
258
+
259
+ ### Example
260
+
261
+ ```javascript
262
+ const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
263
+
264
+ console.log(`Cart ID: ${cart.cartId}`);
265
+ console.log(`Items: ${cart.itemCount}`);
266
+ console.log(`Subtotal: $${cart.subtotal / 100}`);
267
+
268
+ if (cart.promoCodeDiscount) {
269
+ console.log(`Discount: $${cart.promoCodeDiscount / 100}`);
270
+ }
271
+ ```
272
+
273
+ ### Use Cases
274
+
275
+ #### Display Cart Summary
276
+
277
+ ```javascript
278
+ function updateCartSummary() {
279
+ const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
280
+
281
+ document.getElementById('cart-count').textContent = cart.itemCount;
282
+ document.getElementById('cart-total').textContent = `$${cart.subtotal / 100}`;
283
+ }
284
+
285
+ // Update on cart changes
286
+ window.addEventListener('lce:actions.cart_updated', updateCartSummary);
287
+ ```
288
+
289
+ #### Check Cart Before Checkout
290
+
291
+ ```javascript
292
+ document.getElementById('checkout-btn').addEventListener('click', () => {
293
+ const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
294
+
295
+ if (cart.itemCount === 0) {
296
+ alert('Your cart is empty');
297
+ return;
298
+ }
299
+
300
+ window.LiquidCommerce.elements.actions.checkout.openCheckout();
301
+ });
302
+ ```
303
+
304
+ #### Track Cart Value
305
+
306
+ ```javascript
307
+ const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
308
+
309
+ gtag('event', 'view_cart', {
310
+ value: cart.subtotal / 100,
311
+ currency: 'USD',
312
+ items: Object.values(cart.items).map(item => ({
313
+ item_id: item.partNumber,
314
+ quantity: item.quantity
315
+ }))
316
+ });
317
+ ```
318
+
319
+ ## Events
320
+
321
+ Cart actions trigger events that you can listen for:
322
+
323
+ ```javascript
324
+ // Item added
325
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
326
+ console.log('Item added:', event.detail.data);
327
+ });
328
+
329
+ // Cart updated
330
+ window.addEventListener('lce:actions.cart_updated', (event) => {
331
+ console.log('Cart updated:', event.detail.data);
332
+ });
333
+
334
+ // Promo code applied
335
+ window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
336
+ console.log('Promo applied:', event.detail.data);
337
+ });
338
+
339
+ // Product add success
340
+ window.addEventListener('lce:actions.cart_product_add_success', (event) => {
341
+ console.log('Products added:', event.detail.data);
342
+ });
343
+
344
+ // Product add failed
345
+ window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
346
+ console.error('Failed to add:', event.detail.data);
347
+ });
348
+ ```
349
+
350
+ See [Events Guide](../../guides/events.md) for all cart events.
351
+
352
+ ## See Also
353
+
354
+ - [Cart Component Guide](../../guides/cart-component.md)
355
+ - [Cart Events](../../guides/events.md#cart-events)
356
+ - [Product Actions](./product-actions.md)
357
+ - [Checkout Actions](./checkout-actions.md)