@liquidcommerce/elements-sdk 2.6.0-beta.12 → 2.6.0-beta.120

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 (292) hide show
  1. package/README.md +100 -2518
  2. package/dist/index.checkout.esm.js +19988 -0
  3. package/dist/index.esm.js +27974 -20438
  4. package/dist/ssr-stub.checkout.esm.js +17 -0
  5. package/dist/ssr-stub.esm.js +275 -0
  6. package/dist/types/auto-initialize/checkout.d.ts +2 -0
  7. package/dist/types/auto-initialize/shared-utils.d.ts +51 -0
  8. package/dist/types/{elements-base-client.d.ts → clients/base.d.ts} +16 -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/clients/helpers.d.ts +8 -0
  12. package/dist/types/clients/main.d.ts +3 -0
  13. package/dist/types/constants/core.constant.d.ts +13 -18
  14. package/dist/types/constants/index.d.ts +1 -0
  15. package/dist/types/constants/prop65.constant.d.ts +8 -0
  16. package/dist/types/core/a11y/announcer.service.d.ts +16 -0
  17. package/dist/types/core/a11y/focus-manager.service.d.ts +21 -0
  18. package/dist/types/core/a11y/focusable.d.ts +5 -0
  19. package/dist/types/core/a11y/glyph-button.d.ts +8 -0
  20. package/dist/types/core/a11y/index.d.ts +6 -0
  21. package/dist/types/core/a11y/required.d.ts +1 -0
  22. package/dist/types/core/a11y/single-select.d.ts +20 -0
  23. package/dist/types/core/api/api-client.service.d.ts +22 -18
  24. package/dist/types/core/api/api-result.d.ts +19 -0
  25. package/dist/types/core/api/auth-client.service.d.ts +37 -13
  26. package/dist/types/core/api/http-client.service.d.ts +0 -8
  27. package/dist/types/core/base-component.service.d.ts +4 -1
  28. package/dist/types/core/client/actions/base-action.service.d.ts +22 -0
  29. package/dist/types/core/client/actions/client-address-action.service.d.ts +18 -0
  30. package/dist/types/core/client/actions/client-cart-action.service.d.ts +38 -0
  31. package/dist/types/core/client/actions/client-checkout-action.service.d.ts +75 -0
  32. package/dist/types/core/client/actions/client-product-action.service.d.ts +15 -0
  33. package/dist/types/core/client/client-action.service.d.ts +6 -74
  34. package/dist/types/core/client/client-config.service.d.ts +10 -5
  35. package/dist/types/core/debug-panel/debug-panel.styles.d.ts +1 -1
  36. package/dist/types/core/google-tag-manager.service.d.ts +10 -1
  37. package/dist/types/core/logger/logger.service.d.ts +1 -1
  38. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
  39. package/dist/types/core/pubsub/interfaces/cart.interface.d.ts +6 -1
  40. package/dist/types/core/pubsub/interfaces/checkout.interface.d.ts +39 -49
  41. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +14 -7
  42. package/dist/types/core/pubsub/pubsub.service.d.ts +1 -2
  43. package/dist/types/core/singleton-manager.service.d.ts +12 -8
  44. package/dist/types/core/store/interfaces/cart.interface.d.ts +2 -3
  45. package/dist/types/core/store/interfaces/checkout.interface.d.ts +28 -107
  46. package/dist/types/core/store/interfaces/core.interface.d.ts +12 -2
  47. package/dist/types/core/store/interfaces/metadata.interface.d.ts +11 -0
  48. package/dist/types/core/store/interfaces/product-list.interface.d.ts +30 -0
  49. package/dist/types/core/store/interfaces/product.interface.d.ts +1 -0
  50. package/dist/types/core/store/store.constant.d.ts +5 -0
  51. package/dist/types/core/store/store.service.d.ts +1 -0
  52. package/dist/types/core/telemetry/telemetry.service.d.ts +1 -0
  53. package/dist/types/enums/core.enum.d.ts +45 -2
  54. package/dist/types/enums/index.d.ts +0 -1
  55. package/dist/types/index.checkout.d.ts +9 -0
  56. package/dist/types/index.checkout.umd.d.ts +4 -0
  57. package/dist/types/index.d.ts +8 -3
  58. package/dist/types/interfaces/api/cart.interface.d.ts +12 -7
  59. package/dist/types/interfaces/api/checkout.interface.d.ts +246 -0
  60. package/dist/types/interfaces/api/index.d.ts +5 -0
  61. package/dist/types/interfaces/api/product-list.interface.d.ts +15 -6
  62. package/dist/types/interfaces/api/product.interface.d.ts +10 -4
  63. package/dist/types/interfaces/client.interface.d.ts +74 -0
  64. package/dist/types/interfaces/component.interface.d.ts +7 -0
  65. package/dist/types/interfaces/config.interface.d.ts +44 -0
  66. package/dist/types/interfaces/configs/address.interface.d.ts +1 -1
  67. package/dist/types/interfaces/configs/cart.interface.d.ts +2 -1
  68. package/dist/types/interfaces/configs/checkout.interface.d.ts +3 -1
  69. package/dist/types/interfaces/configs/global.interface.d.ts +9 -3
  70. package/dist/types/interfaces/configs/index.d.ts +1 -0
  71. package/dist/types/interfaces/configs/product-list.interface.d.ts +49 -0
  72. package/dist/types/interfaces/configs/product.interface.d.ts +7 -1
  73. package/dist/types/interfaces/injection.interface.d.ts +56 -0
  74. package/dist/types/modules/address/address-display.component.d.ts +3 -1
  75. package/dist/types/modules/address/address-input.component.d.ts +10 -1
  76. package/dist/types/modules/address/address.command.d.ts +2 -1
  77. package/dist/types/modules/address/styles/register-styles.d.ts +1 -0
  78. package/dist/types/modules/cart/cart.commands.d.ts +9 -5
  79. package/dist/types/modules/cart/components/cart-body.component.d.ts +1 -0
  80. package/dist/types/modules/cart/components/cart-fulfillment.component.d.ts +1 -1
  81. package/dist/types/modules/cart/components/cart-item-quantity-price.component.d.ts +5 -0
  82. package/dist/types/modules/cart/components/cart-item.component.d.ts +6 -0
  83. package/dist/types/modules/cart/styles/register-styles.d.ts +1 -0
  84. package/dist/types/modules/checkout/checkout.commands.d.ts +84 -12
  85. package/dist/types/modules/checkout/checkout.component.d.ts +6 -1
  86. package/dist/types/modules/checkout/components/checkout-billing.component.d.ts +5 -2
  87. package/dist/types/modules/checkout/components/checkout-buyer.component.d.ts +1 -0
  88. package/dist/types/modules/checkout/components/checkout-completed.component.d.ts +5 -0
  89. package/dist/types/modules/checkout/components/checkout-deliver-to.component.d.ts +1 -0
  90. package/dist/types/modules/checkout/components/checkout-express-checkout.component.d.ts +61 -0
  91. package/dist/types/modules/checkout/components/checkout-express-completion.component.d.ts +21 -0
  92. package/dist/types/modules/checkout/components/checkout-header.component.d.ts +1 -0
  93. package/dist/types/modules/checkout/components/checkout-item-quantity.component.d.ts +4 -0
  94. package/dist/types/modules/checkout/components/checkout-items.component.d.ts +4 -3
  95. package/dist/types/modules/checkout/components/checkout-order-summary.component.d.ts +3 -0
  96. package/dist/types/modules/checkout/components/checkout-payment.component.d.ts +6 -1
  97. package/dist/types/modules/checkout/components/checkout-place-order-button.component.d.ts +2 -0
  98. package/dist/types/modules/checkout/components/checkout-presale-countdown.component.d.ts +15 -1
  99. package/dist/types/modules/checkout/components/checkout-presale-expired.component.d.ts +7 -1
  100. package/dist/types/modules/checkout/components/checkout-prop65-warning.component.d.ts +8 -0
  101. package/dist/types/modules/checkout/components/checkout-send-as-gift.component.d.ts +3 -0
  102. package/dist/types/modules/checkout/components/checkout-stripe-form.component.d.ts +7 -2
  103. package/dist/types/modules/checkout/components/checkout-tips.component.d.ts +4 -2
  104. package/dist/types/modules/checkout/components/index.d.ts +3 -0
  105. package/dist/types/modules/checkout/components/promo-pc-gc.component.d.ts +0 -2
  106. package/dist/types/modules/checkout/components/required-fields-legend.d.ts +1 -0
  107. package/dist/types/modules/checkout/constant.d.ts +5 -0
  108. package/dist/types/modules/checkout/customer-prefill.d.ts +5 -0
  109. package/dist/types/modules/checkout/express-wallet.d.ts +12 -0
  110. package/dist/types/modules/checkout/payment-session-error.d.ts +4 -0
  111. package/dist/types/modules/checkout/styles/express-checkout.style.d.ts +1 -0
  112. package/dist/types/modules/checkout/styles/express-completion.style.d.ts +1 -0
  113. package/dist/types/modules/checkout/styles/register-styles.d.ts +1 -0
  114. package/dist/types/modules/product/components/components.d.ts +26 -2
  115. package/dist/types/modules/product/components/index.d.ts +1 -0
  116. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +8 -1
  117. package/dist/types/modules/product/components/product-delivery-estimate.component.d.ts +11 -0
  118. package/dist/types/modules/product/components/product-description.component.d.ts +1 -0
  119. package/dist/types/modules/product/components/product-drawer.component.d.ts +6 -0
  120. package/dist/types/modules/product/components/product-image-carousel.component.d.ts +5 -0
  121. package/dist/types/modules/product/components/product-options.component.d.ts +2 -1
  122. package/dist/types/modules/product/components/product-prop65-warning.d.ts +1 -0
  123. package/dist/types/modules/product/components/product-retailers-carousel.component.d.ts +6 -0
  124. package/dist/types/modules/product/components/product-retailers-popup-list.component.d.ts +12 -2
  125. package/dist/types/modules/product/components/product-retailers-popup.component.d.ts +1 -0
  126. package/dist/types/modules/product/components/product-retailers.component.d.ts +1 -0
  127. package/dist/types/modules/product/product.commands.d.ts +5 -5
  128. package/dist/types/modules/product/product.component.d.ts +3 -0
  129. package/dist/types/modules/product/styles/prop65-warning.style.d.ts +1 -0
  130. package/dist/types/modules/product/styles/register-styles.d.ts +1 -0
  131. package/dist/types/modules/product-list/components/card-components/index.d.ts +6 -0
  132. package/dist/types/modules/product-list/components/card-components/product-badge.d.ts +9 -0
  133. package/dist/types/modules/product-list/components/card-components/product-button.d.ts +11 -0
  134. package/dist/types/modules/product-list/components/card-components/product-fulfillment-text.d.ts +2 -0
  135. package/dist/types/modules/product-list/components/card-components/product-price-and-personalization.d.ts +14 -0
  136. package/dist/types/modules/product-list/components/card-components/product-quantity-selector.d.ts +11 -0
  137. package/dist/types/modules/product-list/components/card-components/product-sizes-list.d.ts +14 -0
  138. package/dist/types/modules/product-list/components/filter-components/index.d.ts +7 -0
  139. package/dist/types/modules/product-list/components/filter-components/product-list-apply-filter-button.d.ts +1 -0
  140. 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} +1 -0
  141. package/dist/types/modules/product-list/components/filter-components/product-list-chip.d.ts +5 -0
  142. package/dist/types/modules/product-list/components/filter-components/product-list-filters-chips.d.ts +13 -0
  143. package/dist/types/modules/product-list/components/filter-components/product-list-fulfillment-filter.d.ts +15 -0
  144. 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} +2 -1
  145. package/dist/types/modules/product-list/components/filter-components/product-list-toggle-filters.d.ts +7 -0
  146. package/dist/types/modules/product-list/components/index.d.ts +6 -2
  147. package/dist/types/modules/product-list/components/product-list-card-loading.component.d.ts +3 -1
  148. package/dist/types/modules/product-list/components/product-list-card.component.d.ts +39 -31
  149. package/dist/types/modules/product-list/components/product-list-engraving.component.d.ts +12 -0
  150. package/dist/types/modules/product-list/components/product-list-filters.component.d.ts +58 -36
  151. package/dist/types/modules/product-list/components/product-list-product-engraving-lines.component.d.ts +22 -0
  152. package/dist/types/modules/product-list/components/product-list-product-pre-cart.component.d.ts +54 -0
  153. package/dist/types/modules/product-list/components/product-list-search.component.d.ts +25 -0
  154. package/dist/types/modules/product-list/product-list-filter.registry.d.ts +42 -0
  155. package/dist/types/modules/product-list/product-list-filter.utils.d.ts +7 -0
  156. package/dist/types/modules/product-list/product-list-order.utils.d.ts +3 -0
  157. package/dist/types/modules/product-list/product-list-query-params.utils.d.ts +3 -0
  158. package/dist/types/modules/product-list/product-list.commands.d.ts +22 -7
  159. package/dist/types/modules/product-list/product-list.component.d.ts +23 -47
  160. package/dist/types/modules/product-list/product-list.constants.d.ts +38 -0
  161. package/dist/types/modules/product-list/product-list.interface.d.ts +17 -28
  162. package/dist/types/modules/product-list/styles/product-list-card.style.d.ts +1 -0
  163. package/dist/types/modules/product-list/styles/product-list-filters.style.d.ts +1 -0
  164. package/dist/types/modules/product-list/styles/register-styles.d.ts +1 -0
  165. package/dist/types/modules/theme-provider/constants/component-groupings.d.ts +1 -0
  166. package/dist/types/modules/theme-provider/constants/css-variable-mappings.d.ts +1 -1
  167. package/dist/types/modules/theme-provider/services/style-registry.service.d.ts +16 -0
  168. package/dist/types/modules/theme-provider/services/stylesheet-generator.service.d.ts +0 -1
  169. package/dist/types/modules/theme-provider/styles/register-styles.d.ts +1 -0
  170. package/dist/types/modules/theme-provider/theme-provider.service.d.ts +2 -2
  171. package/dist/types/modules/ui-components/alert/alert.component.d.ts +1 -1
  172. package/dist/types/modules/ui-components/buttons/buttons-open-cart.component.d.ts +5 -0
  173. package/dist/types/modules/ui-components/drawer/drawer.component.d.ts +15 -0
  174. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +9 -1
  175. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +7 -1
  176. package/dist/types/modules/ui-components/input/index.d.ts +0 -1
  177. package/dist/types/modules/ui-components/input/input.component.d.ts +15 -2
  178. package/dist/types/modules/ui-components/lce-element/lce-element.component.d.ts +2 -1
  179. package/dist/types/modules/ui-components/promo-code-ticker/promo-code-ticker.component.d.ts +1 -1
  180. package/dist/types/modules/ui-components/ui.commands.d.ts +7 -1
  181. package/dist/types/ssr/stub.checkout.d.ts +6 -0
  182. package/dist/types/ssr/stub.d.ts +10 -0
  183. package/dist/types/static/icon/arrow-right.icon.d.ts +1 -1
  184. package/dist/types/static/icon/bag.icon.d.ts +1 -1
  185. package/dist/types/static/icon/check.icon.d.ts +2 -0
  186. package/dist/types/static/icon/checkbox.icon.d.ts +1 -1
  187. package/dist/types/static/icon/chevron-down.icon.d.ts +1 -1
  188. package/dist/types/static/icon/chevron-left.icon.d.ts +1 -1
  189. package/dist/types/static/icon/chevron-up.icon.d.ts +1 -1
  190. package/dist/types/static/icon/close.icon.d.ts +1 -1
  191. package/dist/types/static/icon/error-info.icon.d.ts +1 -1
  192. package/dist/types/static/icon/filter.icon.d.ts +1 -1
  193. package/dist/types/static/icon/icon.a11y.d.ts +1 -0
  194. package/dist/types/static/icon/icon.types.d.ts +1 -0
  195. package/dist/types/static/icon/index.d.ts +2 -0
  196. package/dist/types/static/icon/info.icon.d.ts +1 -1
  197. package/dist/types/static/icon/loading-spinner.icon.d.ts +1 -1
  198. package/dist/types/static/icon/search.icon.d.ts +1 -1
  199. package/dist/types/static/icon/success.icon.d.ts +1 -1
  200. package/dist/types/static/icon/trash.icon.d.ts +1 -1
  201. package/dist/types/static/icon/warning.icon.d.ts +1 -1
  202. package/dist/types/utils/dom-compat.d.ts +2 -0
  203. package/dist/types/utils/format.d.ts +9 -14
  204. package/dist/types/utils/image-bg-removal.d.ts +3 -0
  205. package/dist/types/utils/product-selection.d.ts +16 -0
  206. package/dist/types/utils/product.d.ts +21 -0
  207. package/dist/types/utils/timezone.d.ts +6 -0
  208. package/docs/v1/README.md +213 -0
  209. package/docs/v1/api/actions/address-actions.md +286 -0
  210. package/docs/v1/api/actions/cart-actions.md +364 -0
  211. package/docs/v1/api/actions/checkout-actions.md +586 -0
  212. package/docs/v1/api/actions/product-actions.md +204 -0
  213. package/docs/v1/api/client.md +664 -0
  214. package/docs/v1/api/configuration.md +583 -0
  215. package/docs/v1/api/injection-methods.md +331 -0
  216. package/docs/v1/api/typescript-types.md +501 -0
  217. package/docs/v1/api/ui-helpers.md +200 -0
  218. package/docs/v1/examples/advanced-patterns.md +199 -0
  219. package/docs/v1/examples/checkout-flow.md +90 -0
  220. package/docs/v1/examples/custom-theming.md +76 -0
  221. package/docs/v1/examples/multi-product-page.md +90 -0
  222. package/docs/v1/examples/simple-product-page.md +89 -0
  223. package/docs/v1/getting-started/concepts.md +521 -0
  224. package/docs/v1/getting-started/installation.md +351 -0
  225. package/docs/v1/getting-started/quick-start.md +410 -0
  226. package/docs/v1/guides/accessibility.md +280 -0
  227. package/docs/v1/guides/address-component.md +435 -0
  228. package/docs/v1/guides/best-practices.md +365 -0
  229. package/docs/v1/guides/cart-component.md +800 -0
  230. package/docs/v1/guides/checkout-component.md +806 -0
  231. package/docs/v1/guides/events.md +988 -0
  232. package/docs/v1/guides/product-component.md +761 -0
  233. package/docs/v1/guides/product-list-component.md +730 -0
  234. package/docs/v1/guides/theming.md +243 -0
  235. package/docs/v1/integration/angular.md +39 -0
  236. package/docs/v1/integration/laravel.md +41 -0
  237. package/docs/v1/integration/nextjs.md +69 -0
  238. package/docs/v1/integration/proxy-setup.md +106 -0
  239. package/docs/v1/integration/react.md +64 -0
  240. package/docs/v1/integration/vanilla-js.md +84 -0
  241. package/docs/v1/integration/vue.md +58 -0
  242. package/docs/v1/reference/analytics.md +133 -0
  243. package/docs/v1/reference/browser-support.md +47 -0
  244. package/docs/v1/reference/error-handling.md +83 -0
  245. package/docs/v1/reference/performance.md +52 -0
  246. package/docs/v1/reference/telemetry.md +85 -0
  247. package/docs/v1/reference/troubleshooting.md +135 -0
  248. package/package.json +75 -45
  249. package/dist/types/elements-builder-client.d.ts +0 -2
  250. package/dist/types/elements-client-helper.d.ts +0 -4
  251. package/dist/types/elements-client.d.ts +0 -2
  252. package/dist/types/enums/cloud.enum.d.ts +0 -97
  253. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
  254. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  255. package/dist/types/interfaces/cloud/index.d.ts +0 -3
  256. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  257. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  258. package/dist/types/interfaces/core.interface.d.ts +0 -111
  259. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  260. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  261. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  262. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  263. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
  264. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  265. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  266. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  267. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  268. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  269. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  270. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  271. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  272. package/dist/types/utils/helper.d.ts +0 -28
  273. package/docs/ACTIONS.md +0 -1300
  274. package/docs/BROWSER_SUPPORT.md +0 -279
  275. package/docs/CONFIGURATION.md +0 -853
  276. package/docs/DOCUMENTATION_INDEX.md +0 -311
  277. package/docs/EVENTS.md +0 -798
  278. package/docs/PROXY.md +0 -228
  279. package/docs/THEMING.md +0 -592
  280. package/docs/TROUBLESHOOTING.md +0 -793
  281. package/umd/elements.js +0 -1
  282. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  283. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  284. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  285. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  286. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  287. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  288. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  289. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  290. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  291. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  292. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -0,0 +1,800 @@
1
+ # Cart Component
2
+
3
+ The Cart component provides a slide-out drawer for managing shopping cart items, applying promo codes, and proceeding to checkout.
4
+
5
+ ## Overview
6
+
7
+ The Cart component automatically:
8
+ - Displays cart items with images and details
9
+ - Removes white / near-white backgrounds from item images so products blend into the drawer (automatic, not host-configurable)
10
+ - Groups items by retailer
11
+ - Shows real-time pricing and totals
12
+ - Supports quantity updates
13
+ - Handles promo code application
14
+ - Persists cart across sessions and tabs
15
+ - Provides checkout navigation
16
+
17
+ ## Basic Usage
18
+
19
+ The cart is automatically available when using the SDK - no explicit injection needed for the drawer. However, you need a way for users to open it.
20
+
21
+ ### Cart Buttons
22
+
23
+ #### Declarative Cart Button
24
+
25
+ Add a cart button using data attributes on the SDK script:
26
+
27
+ ```html
28
+ <script
29
+ defer
30
+ data-liquid-commerce-elements
31
+ data-token="YOUR_API_KEY"
32
+ data-env="production"
33
+ data-cart-button="header-cart"
34
+ type="text/javascript"
35
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
36
+ ></script>
37
+
38
+ <div id="header-cart"></div>
39
+ ```
40
+
41
+ #### Cart Button with Item Count Badge
42
+
43
+ Show the number of items in the cart:
44
+
45
+ ```html
46
+ <script
47
+ defer
48
+ data-liquid-commerce-elements
49
+ data-token="YOUR_API_KEY"
50
+ data-env="production"
51
+ data-cart-badge-button="header-cart"
52
+ type="text/javascript"
53
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
54
+ ></script>
55
+
56
+ <div id="header-cart"></div>
57
+ ```
58
+
59
+ #### Floating Cart Button
60
+
61
+ Create a floating button (top-right corner):
62
+
63
+ ```html
64
+ <script
65
+ defer
66
+ data-liquid-commerce-elements
67
+ data-token="YOUR_API_KEY"
68
+ data-env="production"
69
+ data-cart-button
70
+ type="text/javascript"
71
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
72
+ ></script>
73
+ ```
74
+
75
+ Leaving `data-cart-button` empty creates a floating button automatically.
76
+
77
+ #### Positional Cart Button
78
+
79
+ Control where the cart button appears:
80
+
81
+ ```html
82
+ <!-- Inside an element -->
83
+ <script data-cart-button="inside:#header"></script>
84
+
85
+ <!-- Above an element -->
86
+ <script data-cart-button="above:.navigation"></script>
87
+
88
+ <!-- Below an element -->
89
+ <script data-cart-button="below:#logo"></script>
90
+
91
+ <!-- Replace an element -->
92
+ <script data-cart-button="replace:#cart-placeholder"></script>
93
+ ```
94
+
95
+ #### Hide Cart Button
96
+
97
+ If you want to control cart opening manually:
98
+
99
+ ```html
100
+ <script
101
+ defer
102
+ data-liquid-commerce-elements
103
+ data-token="YOUR_API_KEY"
104
+ data-env="production"
105
+ data-cart-button-hidden
106
+ type="text/javascript"
107
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
108
+ ></script>
109
+ ```
110
+
111
+ #### Programmatic Cart Button
112
+
113
+ Create cart buttons using JavaScript:
114
+
115
+ ```javascript
116
+ // Button in a container
117
+ window.LiquidCommerce.elements.ui.cartButton('my-container', false); // No badge
118
+
119
+ // Button with item count
120
+ window.LiquidCommerce.elements.ui.cartButton('my-container', true); // With badge
121
+
122
+ // Floating button
123
+ window.LiquidCommerce.elements.ui.floatingCartButton(true); // With badge
124
+ ```
125
+
126
+ ### Custom Toggle Buttons
127
+
128
+ Use your own button to toggle the cart:
129
+
130
+ ```html
131
+ <button data-lce-cart-toggle-button>
132
+ View Cart
133
+ </button>
134
+ ```
135
+
136
+ The SDK automatically adds click handlers to elements with `data-lce-cart-toggle-button`.
137
+
138
+ ## Cart Actions
139
+
140
+ ### Open Cart
141
+
142
+ ```javascript
143
+ window.LiquidCommerce.elements.actions.cart.openCart();
144
+ ```
145
+
146
+ ### Close Cart
147
+
148
+ ```javascript
149
+ window.LiquidCommerce.elements.actions.cart.closeCart();
150
+ ```
151
+
152
+ ### Toggle Cart
153
+
154
+ ```javascript
155
+ window.LiquidCommerce.elements.actions.cart.toggleCart();
156
+ ```
157
+
158
+ ### Add Product to Cart
159
+
160
+ Add products programmatically:
161
+
162
+ ```javascript
163
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
164
+ {
165
+ identifier: '00619947000020',
166
+ fulfillmentType: 'shipping', // or 'onDemand'
167
+ quantity: 2
168
+ },
169
+ {
170
+ identifier: '08504405135',
171
+ fulfillmentType: 'onDemand',
172
+ quantity: 1
173
+ }
174
+ ], true); // true = open cart after adding
175
+ ```
176
+
177
+ **Parameters:**
178
+ - `identifier` (string): Product UPC, size ID, or salsifyGrouping ID
179
+ - `fulfillmentType` (string): `'shipping'` or `'onDemand'`
180
+ - `quantity` (number): Number of items (default: 1)
181
+ - `engravingLines` (string[], optional): Engraving text lines for the product (applied when the product/variant supports engraving; ignored otherwise)
182
+ - Second parameter (boolean): Open cart after adding (default: false)
183
+
184
+ ### Apply Promo Code
185
+
186
+ ```javascript
187
+ await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
188
+ ```
189
+
190
+ The SDK automatically:
191
+ - Validates the promo code
192
+ - Calculates discount
193
+ - Updates cart totals
194
+ - Shows success/error message
195
+
196
+ ### Remove Promo Code
197
+
198
+ ```javascript
199
+ await window.LiquidCommerce.elements.actions.cart.removePromoCode();
200
+ ```
201
+
202
+ ### Reset Cart
203
+
204
+ Clear all items from the cart:
205
+
206
+ ```javascript
207
+ await window.LiquidCommerce.elements.actions.cart.resetCart();
208
+ ```
209
+
210
+ ### Get Cart Details
211
+
212
+ Retrieve current cart information:
213
+
214
+ ```javascript
215
+ const cartData = window.LiquidCommerce.elements.actions.cart.getDetails();
216
+
217
+ console.log(cartData);
218
+ // {
219
+ // cartId: 'cart_abc123',
220
+ // promoCodeDiscount: 1000, // number | null
221
+ // subtotal: 9998, // in cents
222
+ // itemCount: 5,
223
+ // items: {...}, // Record<itemId, ICartItem>
224
+ // retailers: {...}, // Record<retailerId, ICartRetailer>
225
+ // location: {...}, // or null
226
+ // ...
227
+ // }
228
+ ```
229
+
230
+ ## Cart UI Helpers
231
+
232
+ ### Display Cart Subtotal
233
+
234
+ Show cart subtotal anywhere on your page:
235
+
236
+ ```html
237
+ <div>
238
+ Cart Total: <span id="cart-total"></span>
239
+ </div>
240
+
241
+ <script>
242
+ window.addEventListener('lce:actions.client_ready', () => {
243
+ window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
244
+ }, { once: true });
245
+ </script>
246
+ ```
247
+
248
+ The element automatically updates when the cart changes.
249
+
250
+ ### Display Items Count
251
+
252
+ Show the number of items in the cart:
253
+
254
+ ```html
255
+ <div>
256
+ Items: <span id="items-count"></span>
257
+ </div>
258
+
259
+ <script>
260
+ window.addEventListener('lce:actions.client_ready', () => {
261
+ window.LiquidCommerce.elements.ui.cartItemsCount('items-count', {
262
+ hideZero: true // Hide when cart is empty
263
+ });
264
+ }, { once: true });
265
+ </script>
266
+ ```
267
+
268
+ Or using data attributes:
269
+
270
+ ```html
271
+ <!-- Always show count, even when 0 -->
272
+ <span data-lce-cart-items-count="keep-zero"></span>
273
+
274
+ <!-- Hide when 0 (default behavior) -->
275
+ <span data-lce-cart-items-count></span>
276
+ ```
277
+
278
+ ## Events
279
+
280
+ ### `lce:actions.cart_shop_retailer`
281
+
282
+ A shopper activated **Shop {retailer}** from an unmet cart fulfillment minimum. Opt in with
283
+ `customTheme.cart.layout.showShopRetailerButton: true` (default `false`). The cart command
284
+ revalidates the fulfillment, its current retailer and items, fulfillment type, and remaining
285
+ minimum before emitting. Unsupported, empty, stale or already-satisfied fulfillments emit nothing.
286
+
287
+ ```typescript
288
+ interface ICartShopRetailerEventData {
289
+ retailerId: string;
290
+ fulfillmentId: string;
291
+ fulfillmentType: 'onDemand' | 'shipping';
292
+ }
293
+ ```
294
+
295
+ Listen with the exported constant; the usual event envelope is `{ data, metadata }`:
296
+
297
+ ```javascript
298
+ window.addEventListener(`lce:actions.${ELEMENTS_ACTIONS_EVENT.CART_SHOP_RETAILER}`, (event) => {
299
+ const { retailerId, fulfillmentId, fulfillmentType } = event.detail.data;
300
+ // Revalidate against client.actions.cart.getDetails(), then close the drawer
301
+ // and route to your catalog scoped to this retailer and fulfillment type.
302
+ });
303
+ ```
304
+
305
+ The SDK leaves the drawer open and does not navigate. The host handles routing and derives
306
+ retailer names, totals and minimums from current cart details. The event is also sent to `lce:actions`.
307
+
308
+
309
+
310
+ ### Cart Loaded
311
+
312
+ Fired when cart data is loaded:
313
+
314
+ ```javascript
315
+ window.addEventListener('lce:actions.cart_loaded', (event) => {
316
+ const { cartId, itemCount, subtotal } = event.detail.data;
317
+ console.log(`Cart loaded: ${itemCount} items, total: $${subtotal / 100}`);
318
+ });
319
+ ```
320
+
321
+ ### Cart Opened/Closed
322
+
323
+ ```javascript
324
+ window.addEventListener('lce:actions.cart_opened', (event) => {
325
+ console.log('Cart drawer opened');
326
+ });
327
+
328
+ window.addEventListener('lce:actions.cart_closed', (event) => {
329
+ console.log('Cart drawer closed');
330
+ });
331
+ ```
332
+
333
+ ### Cart Updated
334
+
335
+ Fired whenever cart contents change:
336
+
337
+ ```javascript
338
+ window.addEventListener('lce:actions.cart_updated', (event) => {
339
+ const { cartId, itemCount, subtotal } = event.detail.data.current;
340
+ console.log('Cart updated:', itemCount, 'items');
341
+ });
342
+ ```
343
+
344
+ ### Item Added
345
+
346
+ ```javascript
347
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
348
+ const { cartId, itemId, quantity } = event.detail.data;
349
+ console.log(`Item ${itemId} added (quantity: ${quantity})`);
350
+ });
351
+ ```
352
+
353
+ ### Item Removed
354
+
355
+ ```javascript
356
+ window.addEventListener('lce:actions.cart_item_removed', (event) => {
357
+ const { cartId, itemId } = event.detail.data;
358
+ console.log(`Item ${itemId} removed`);
359
+ });
360
+ ```
361
+
362
+ ### Quantity Changed
363
+
364
+ ```javascript
365
+ window.addEventListener('lce:actions.cart_item_quantity_increase', (event) => {
366
+ const { cartId, itemId, quantity } = event.detail.data;
367
+ console.log(`Item ${itemId} quantity increased to ${quantity}`);
368
+ });
369
+
370
+ window.addEventListener('lce:actions.cart_item_quantity_decrease', (event) => {
371
+ const { cartId, itemId, quantity } = event.detail.data;
372
+ console.log(`Item ${itemId} quantity decreased to ${quantity}`);
373
+ });
374
+ ```
375
+
376
+ ### Engraving Updated
377
+
378
+ Fired when a cart line item's engraving is added or edited from the drawer (see [Engraving](#engraving)):
379
+
380
+ ```javascript
381
+ window.addEventListener('lce:actions.cart_item_engraving_updated', (event) => {
382
+ const { cartId, itemId, engravingLines, previousEngravingLines } = event.detail.data;
383
+ console.log(`Engraving updated for ${itemId}:`, engravingLines);
384
+ });
385
+ ```
386
+
387
+ ### Promo Code Events
388
+
389
+ ```javascript
390
+ window.addEventListener('lce:actions.cart_promo_code_applied', (event) => {
391
+ const { cartId, discount, newSubtotal } = event.detail.data;
392
+ console.log(`Promo code applied: $${discount / 100} off`);
393
+ });
394
+
395
+ window.addEventListener('lce:actions.cart_promo_code_removed', (event) => {
396
+ const { cartId, newSubtotal } = event.detail.data;
397
+ console.log('Promo code removed');
398
+ });
399
+
400
+ window.addEventListener('lce:actions.cart_promo_code_failed', (event) => {
401
+ const { cartId, error } = event.detail.data;
402
+ console.error('Promo code failed:', error);
403
+ });
404
+ ```
405
+
406
+ ### Product Add Success/Failure
407
+
408
+ ```javascript
409
+ window.addEventListener('lce:actions.cart_product_add_success', (event) => {
410
+ const { cartId, itemsAdded, identifiers } = event.detail.data;
411
+ console.log(`Successfully added ${itemsAdded} products`);
412
+ });
413
+
414
+ window.addEventListener('lce:actions.cart_product_add_failed', (event) => {
415
+ const { cartId, identifiers, error } = event.detail.data;
416
+ console.error('Failed to add products:', error);
417
+ });
418
+ ```
419
+
420
+ ### Cart Reset
421
+
422
+ ```javascript
423
+ window.addEventListener('lce:actions.cart_reset', (event) => {
424
+ console.log('Cart has been reset');
425
+ });
426
+ ```
427
+
428
+ ## Customization
429
+
430
+ ### Theme Configuration
431
+
432
+ Customize cart appearance:
433
+
434
+ ```javascript
435
+ const client = await Elements('YOUR_API_KEY', {
436
+ env: 'production',
437
+ customTheme: {
438
+ cart: {
439
+ theme: {
440
+ backgroundColor: '#ffffff'
441
+ },
442
+ layout: {
443
+ showShopRetailerButton: false, // Enable only with a cart_shop_retailer event handler
444
+ showQuantityCounter: true,
445
+ quantityCounterStyle: 'outlined', // or 'ghost'
446
+ drawerHeaderText: 'My Bag',
447
+ goToCheckoutButtonText: 'Checkout'
448
+ }
449
+ }
450
+ }
451
+ });
452
+ ```
453
+
454
+ ### Shop the same retailer
455
+
456
+ Set `customTheme.cart.layout.showShopRetailerButton: true` to show a native **Shop {retailer}**
457
+ button beside each unmet order-minimum warning (below it on mobile). The default is `false`,
458
+ including when the server theme predates this option. It only appears for a current, nonempty
459
+ `onDemand` or `shipping` fulfillment with a positive amount remaining and valid retailer ownership.
460
+
461
+ Handle `ELEMENTS_ACTIONS_EVENT.CART_SHOP_RETAILER` (`lce:actions.cart_shop_retailer`) to close the
462
+ cart and open your retailer-filtered catalog. The SDK emits identifiers only and performs no
463
+ navigation. Revalidate them against `client.actions.cart.getDetails()` before navigating; see
464
+ [Events](./events.md) for the payload.
465
+
466
+ ## State Persistence
467
+
468
+ ### Local Storage
469
+
470
+ The cart automatically persists to `localStorage`
471
+
472
+ This allows the cart to survive:
473
+ - Page refreshes
474
+ - Browser restarts
475
+ - Navigation between pages
476
+
477
+ ### Cross-Tab Persistence
478
+
479
+ The cart is persisted to `localStorage` and reloaded on a fresh page load. The SDK does **not** provide live cross-tab synchronization — changes made in one tab will not automatically appear in other already-open tabs (there is no `storage` listener, `BroadcastChannel`, or polling). Another tab reflects the change only after it reloads.
480
+
481
+ ### Session Duration
482
+
483
+ Cart and address session IDs are persisted in `localStorage` (with an API fallback) and are not automatically cleared by the SDK; cart lifetime/expiry is governed by server-side policy.
484
+
485
+ ## Address Requirement
486
+
487
+ The cart requires a delivery address for:
488
+ - Accurate availability
489
+ - Correct pricing
490
+ - Shipping calculations
491
+
492
+ ### Automatic Address Prompt
493
+
494
+ If no address is set when adding to cart, the SDK:
495
+ 1. Opens address input drawer
496
+ 2. Waits for user to set address
497
+ 3. Retries the add-to-cart operation
498
+
499
+ ### Pre-set Address
500
+
501
+ Set address before adding to cart:
502
+
503
+ ```javascript
504
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJ...');
505
+
506
+ // Now add to cart
507
+ await window.LiquidCommerce.elements.actions.cart.addProduct([...]);
508
+ ```
509
+
510
+ ## Promo Codes
511
+
512
+ ### Configuration
513
+
514
+ Enable/disable promo codes globally:
515
+
516
+ ```javascript
517
+ customTheme: {
518
+ global: {
519
+ layout: {
520
+ allowPromoCodes: true // or false to disable
521
+ }
522
+ }
523
+ }
524
+ ```
525
+
526
+ ### Promo Ticker
527
+
528
+ Show promotional codes in a scrolling ticker:
529
+
530
+ ```javascript
531
+ const client = await Elements('YOUR_API_KEY', {
532
+ env: 'production',
533
+ promoTicker: [
534
+ {
535
+ promoCode: 'SUMMER20',
536
+ text: ['20% Off Summer Sale', 'Free Shipping on Orders Over $50'],
537
+ separator: '•',
538
+ activeFrom: '2024-06-01T00:00:00Z',
539
+ activeUntil: '2024-08-31T23:59:59Z'
540
+ }
541
+ ]
542
+ });
543
+ ```
544
+
545
+ Or with data attributes:
546
+
547
+ ```html
548
+ <script
549
+ defer
550
+ data-liquid-commerce-elements
551
+ data-token="YOUR_API_KEY"
552
+ data-env="production"
553
+ data-promo-code="SUMMER20"
554
+ data-promo-text="20% Off Summer Sale | Free Shipping on Orders Over $50"
555
+ data-promo-separator="•"
556
+ data-promo-active-from="2024-06-01T00:00:00Z"
557
+ data-promo-active-until="2024-08-31T23:59:59Z"
558
+ type="text/javascript"
559
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
560
+ ></script>
561
+ ```
562
+
563
+ ### Auto-Apply from URL
564
+
565
+ Apply promo codes automatically via URL parameters:
566
+
567
+ ```html
568
+ <script
569
+ defer
570
+ data-liquid-commerce-elements
571
+ data-token="YOUR_API_KEY"
572
+ data-env="production"
573
+ data-promo-code-param="lce_promo"
574
+ type="text/javascript"
575
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
576
+ ></script>
577
+ ```
578
+
579
+ Now visiting `https://yoursite.com?lce_promo=SUMMER20` automatically applies the code.
580
+
581
+ **Security Note:** Query parameters must start with `lce_` prefix to prevent conflicts with your application.
582
+
583
+ ## Retailer Grouping
584
+
585
+ Items are automatically grouped by retailer in the cart:
586
+
587
+ ```
588
+ ┌─────────────────────────────────────┐
589
+ │ Cart (3 items) │
590
+ ├─────────────────────────────────────┤
591
+ │ Spirits Shop │
592
+ │ • Premium Whiskey (750ml) $49 │
593
+ │ • Bourbon Bottle (1L) $65 │
594
+ │ │
595
+ │ Wine & More │
596
+ │ • Red Wine (750ml) $25 │
597
+ ├─────────────────────────────────────┤
598
+ │ Subtotal: $139 │
599
+ │ Promo Code (SUMMER20): -$28 │
600
+ │ Total: $111 │
601
+ └─────────────────────────────────────┘
602
+ ```
603
+
604
+ ## Order Minimums
605
+
606
+ Retailers can require a minimum purchase amount before their items can be checked out. The cart enforces this per retailer:
607
+
608
+ - When a retailer's minimum is not met, the cart drawer shows a per-retailer alert reading `+$X needed for order minimum`, where `$X` is the remaining amount required for that retailer.
609
+ - The **Checkout** button is disabled until every retailer's minimum is met. (It is also disabled while the cart is loading/updating or when the cart is empty.)
610
+
611
+ No configuration is required — the minimums are defined by each retailer and enforced automatically.
612
+
613
+ ## Engraving
614
+
615
+ For engravable items, shoppers can add or edit engraving directly from a cart line item, without leaving the drawer.
616
+
617
+ - If an engravable item has no engraving yet, the line item shows an **Add personalization** action (with the engraving fee) that opens the engraving form.
618
+ - If the item already has engraving, its engraving is shown on the line item with an **Edit** button that reopens the form.
619
+
620
+ The form respects the item's engraving constraints — `maxLines`, `maxCharsPerLine`, and the per-item `fee`. Saving emits [`lce:actions.cart_item_engraving_updated`](#engraving-updated) with the item's `engravingLines` and `previousEngravingLines`.
621
+
622
+ **Note:** This in-drawer editing is distinct from the `engravingLines` array passed to [`addProduct`](#add-product-to-cart), which pre-fills engraving at the time an item is added.
623
+
624
+ ## Checkout Navigation
625
+
626
+ ### Checkout Drawer (Default)
627
+
628
+ By default, clicking "Checkout" opens the checkout drawer:
629
+
630
+ ```javascript
631
+ // User clicks checkout
632
+ // Checkout drawer slides in
633
+ ```
634
+
635
+ ### Checkout Page (Custom URL)
636
+
637
+ Redirect to a custom checkout page:
638
+
639
+ ```javascript
640
+ const client = await Elements('YOUR_API_KEY', {
641
+ env: 'production',
642
+ checkout: {
643
+ pageUrl: 'https://yoursite.com/checkout/{token}'
644
+ }
645
+ });
646
+ ```
647
+
648
+ Or with data attributes:
649
+
650
+ ```html
651
+ <script
652
+ defer
653
+ data-liquid-commerce-elements
654
+ data-token="YOUR_API_KEY"
655
+ data-env="production"
656
+ data-checkout-url="https://yoursite.com/checkout/{token}"
657
+ type="text/javascript"
658
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
659
+ ></script>
660
+ ```
661
+
662
+ The `{token}` placeholder is replaced with the session checkout token.
663
+
664
+ ## Use Cases
665
+
666
+ ### E-commerce Site
667
+
668
+ ```javascript
669
+ // Track cart events for analytics
670
+ window.addEventListener('lce:actions.cart_item_added', (event) => {
671
+ const { itemId, quantity } = event.detail.data;
672
+ gtag('event', 'add_to_cart', {
673
+ items: [{ item_id: itemId, quantity }],
674
+ currency: 'USD'
675
+ });
676
+ });
677
+
678
+ window.addEventListener('lce:actions.cart_updated', (event) => {
679
+ // Update header cart count
680
+ document.getElementById('cart-badge').textContent =
681
+ event.detail.data.current.itemCount;
682
+ });
683
+ ```
684
+
685
+ ### Marketing Campaign
686
+
687
+ ```javascript
688
+ // Check URL for campaign parameter
689
+ const params = new URLSearchParams(window.location.search);
690
+ const campaign = params.get('campaign');
691
+
692
+ if (campaign === 'summer-sale') {
693
+ await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
694
+ window.LiquidCommerce.elements.actions.cart.openCart();
695
+ }
696
+ ```
697
+
698
+ ### Abandoned Cart Recovery
699
+
700
+ ```javascript
701
+ // Store cart ID in your system
702
+ window.addEventListener('lce:actions.cart_updated', (event) => {
703
+ const { cartId, itemCount } = event.detail.data.current;
704
+
705
+ if (itemCount > 0) {
706
+ // Send cart ID to your backend for abandoned cart emails
707
+ fetch('/api/track-cart', {
708
+ method: 'POST',
709
+ body: JSON.stringify({ cartId, userId: currentUserId })
710
+ });
711
+ }
712
+ });
713
+ ```
714
+
715
+ ## Best Practices
716
+
717
+ ### Initialize Cart Early
718
+
719
+ Pre-load cart on page load for faster access:
720
+
721
+ ```javascript
722
+ window.addEventListener('lce:actions.client_ready', () => {
723
+ // Cart loads automatically, but you can pre-fetch if needed
724
+ window.LiquidCommerce.elements.actions.cart.getDetails();
725
+ }, { once: true });
726
+ ```
727
+
728
+ ### Provide Visual Feedback
729
+
730
+ Show loading states when adding to cart:
731
+
732
+ ```javascript
733
+ async function addToCart(productId) {
734
+ const button = document.getElementById('add-to-cart-btn');
735
+ button.disabled = true;
736
+ button.textContent = 'Adding...';
737
+
738
+ try {
739
+ await window.LiquidCommerce.elements.actions.cart.addProduct([
740
+ { identifier: productId, fulfillmentType: 'shipping', quantity: 1 }
741
+ ], true);
742
+
743
+ button.textContent = 'Added!';
744
+ setTimeout(() => {
745
+ button.disabled = false;
746
+ button.textContent = 'Add to Cart';
747
+ }, 2000);
748
+ } catch (error) {
749
+ button.textContent = 'Failed';
750
+ button.disabled = false;
751
+ }
752
+ }
753
+ ```
754
+
755
+ ### Handle Empty Cart
756
+
757
+ Show appropriate messaging for empty carts:
758
+
759
+ ```javascript
760
+ window.addEventListener('lce:actions.cart_updated', (event) => {
761
+ const { itemCount } = event.detail.data.current;
762
+
763
+ if (itemCount === 0) {
764
+ // Show empty state in your UI
765
+ document.getElementById('cart-status').textContent =
766
+ 'Your cart is empty';
767
+ }
768
+ });
769
+ ```
770
+
771
+ ## Troubleshooting
772
+
773
+ ### Cart Not Opening
774
+
775
+ 1. Check that SDK is initialized: `console.log(window.LiquidCommerce.elements)`
776
+ 2. Verify no JavaScript errors in console
777
+ 3. Ensure cart button is properly configured
778
+ 4. Try manually: `window.LiquidCommerce.elements.actions.cart.openCart()`
779
+
780
+ ### Items Not Adding
781
+
782
+ 1. Check that address is set: `window.LiquidCommerce.elements.actions.address.getDetails()`
783
+ 2. Verify product identifier is valid
784
+ 3. Check fulfillment type is available for the product
785
+ 4. Look for errors in browser console
786
+
787
+ ### Promo Code Not Working
788
+
789
+ 1. Verify promo codes are enabled in configuration
790
+ 2. Check code is valid and active
791
+ 3. Ensure code hasn't already been applied
792
+ 4. Check console for error messages
793
+
794
+ ## See Also
795
+
796
+ - [Product Component](./product-component.md) - Add products to cart
797
+ - [Checkout Component](./checkout-component.md) - Complete purchase
798
+ - [Actions API](../api/actions/cart-actions.md) - Cart actions reference
799
+ - [Events](./events.md) - All available events
800
+ - [Theming](./theming.md) - Customize appearance