@liquidcommerce/elements-sdk 2.6.0-beta.10 → 2.6.0-beta.101

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