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

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 (226) hide show
  1. package/README.md +84 -2520
  2. package/dist/index.checkout.esm.js +16946 -0
  3. package/dist/index.esm.js +24448 -21193
  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 +36 -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/image-bg-removal.d.ts +3 -0
  142. package/dist/types/utils/product-selection.d.ts +16 -0
  143. package/dist/types/utils/product.d.ts +15 -0
  144. package/docs/v1/README.md +210 -0
  145. package/docs/v1/api/actions/address-actions.md +286 -0
  146. package/docs/v1/api/actions/cart-actions.md +357 -0
  147. package/docs/v1/api/actions/checkout-actions.md +525 -0
  148. package/docs/v1/api/actions/product-actions.md +204 -0
  149. package/docs/v1/api/client.md +517 -0
  150. package/docs/v1/api/configuration.md +532 -0
  151. package/docs/v1/api/injection-methods.md +292 -0
  152. package/docs/v1/api/typescript-types.md +419 -0
  153. package/docs/v1/api/ui-helpers.md +200 -0
  154. package/docs/v1/examples/advanced-patterns.md +199 -0
  155. package/docs/v1/examples/checkout-flow.md +90 -0
  156. package/docs/v1/examples/custom-theming.md +63 -0
  157. package/docs/v1/examples/multi-product-page.md +90 -0
  158. package/docs/v1/examples/simple-product-page.md +89 -0
  159. package/docs/v1/getting-started/concepts.md +502 -0
  160. package/docs/v1/getting-started/installation.md +328 -0
  161. package/docs/v1/getting-started/quick-start.md +405 -0
  162. package/docs/v1/guides/address-component.md +435 -0
  163. package/docs/v1/guides/best-practices.md +365 -0
  164. package/docs/v1/guides/cart-component.md +725 -0
  165. package/docs/v1/guides/checkout-component.md +670 -0
  166. package/docs/v1/guides/events.md +926 -0
  167. package/docs/v1/guides/product-component.md +731 -0
  168. package/docs/v1/guides/product-list-component.md +631 -0
  169. package/docs/v1/guides/theming.md +213 -0
  170. package/docs/v1/integration/angular.md +39 -0
  171. package/docs/v1/integration/laravel.md +41 -0
  172. package/docs/v1/integration/nextjs.md +69 -0
  173. package/docs/v1/integration/proxy-setup.md +106 -0
  174. package/docs/v1/integration/react.md +64 -0
  175. package/docs/v1/integration/vanilla-js.md +84 -0
  176. package/docs/v1/integration/vue.md +58 -0
  177. package/docs/v1/reference/browser-support.md +45 -0
  178. package/docs/v1/reference/error-handling.md +75 -0
  179. package/docs/v1/reference/performance.md +52 -0
  180. package/docs/v1/reference/troubleshooting.md +136 -0
  181. package/package.json +33 -37
  182. package/dist/types/elements-builder-client.d.ts +0 -2
  183. package/dist/types/elements-client.d.ts +0 -2
  184. package/dist/types/enums/cloud.enum.d.ts +0 -106
  185. package/dist/types/interfaces/cloud/catalog.interface.d.ts +0 -42
  186. package/dist/types/interfaces/cloud/checkout.interface.d.ts +0 -218
  187. package/dist/types/interfaces/cloud/core.interface.d.ts +0 -22
  188. package/dist/types/interfaces/cloud/index.d.ts +0 -4
  189. package/dist/types/interfaces/cloud/retailer.interface.d.ts +0 -67
  190. package/dist/types/interfaces/cloud/user.interface.d.ts +0 -100
  191. package/dist/types/interfaces/core.interface.d.ts +0 -111
  192. package/dist/types/modules/checkout/components/checkout.type.d.ts +0 -4
  193. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/index.d.ts +0 -6
  194. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-apply-filter-button.component.d.ts +0 -1
  195. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-delivery-options-filter.components.d.ts +0 -16
  196. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-search.component.d.ts +0 -16
  197. package/dist/types/modules/product-list/components/product-list-filters-subcomponents/product-list-toggle-filters.components.d.ts +0 -18
  198. package/dist/types/modules/theme-provider/styles/address/index.d.ts +0 -1
  199. package/dist/types/modules/theme-provider/styles/cart/index.d.ts +0 -1
  200. package/dist/types/modules/theme-provider/styles/checkout/index.d.ts +0 -1
  201. package/dist/types/modules/theme-provider/styles/product/index.d.ts +0 -3
  202. package/dist/types/modules/theme-provider/styles/product-list/index.d.ts +0 -1
  203. package/dist/types/modules/theme-provider/styles/ui/index.d.ts +0 -3
  204. package/dist/types/modules/ui-components/input/birthdate-input.component.d.ts +0 -53
  205. package/dist/types/utils/helper.d.ts +0 -28
  206. package/docs/ACTIONS.md +0 -1300
  207. package/docs/BROWSER_SUPPORT.md +0 -279
  208. package/docs/CONFIGURATION.md +0 -853
  209. package/docs/DOCUMENTATION_INDEX.md +0 -311
  210. package/docs/EVENTS.md +0 -798
  211. package/docs/PROXY.md +0 -228
  212. package/docs/THEMING.md +0 -592
  213. package/docs/TROUBLESHOOTING.md +0 -793
  214. package/umd/elements.js +0 -1
  215. /package/dist/types/{auto-initialize.d.ts → auto-initialize/main.d.ts} +0 -0
  216. /package/dist/types/modules/{theme-provider/styles/address → address/styles}/address.style.d.ts +0 -0
  217. /package/dist/types/modules/{theme-provider/styles/cart → cart/styles}/cart.style.d.ts +0 -0
  218. /package/dist/types/modules/{theme-provider/styles/checkout → checkout/styles}/checkout.style.d.ts +0 -0
  219. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/image-carousel.style.d.ts +0 -0
  220. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/product.style.d.ts +0 -0
  221. /package/dist/types/modules/{theme-provider/styles/product → product/styles}/retailers.style.d.ts +0 -0
  222. /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
  223. /package/dist/types/modules/{theme-provider/styles/product-list → product-list/styles}/product-list.style.d.ts +0 -0
  224. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/drawer.style.d.ts +0 -0
  225. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/loading.style.d.ts +0 -0
  226. /package/dist/types/modules/{theme-provider/styles/ui → ui-components/styles}/promo-code-ticker.style.d.ts +0 -0
@@ -0,0 +1,435 @@
1
+ # Address Component
2
+
3
+ The Address component manages delivery location for availability checking and accurate pricing throughout the SDK.
4
+
5
+ ## Overview
6
+
7
+ The Address component:
8
+ - Provides location input via Google Places integration
9
+ - Allows manual address entry
10
+ - Stores location for cart/checkout
11
+ - Enables location-based pricing
12
+ - Determines product availability
13
+ - Supports fulfillment type selection
14
+
15
+ ## How It Works
16
+
17
+ The address component is **embedded in the product component by default**. Users set their address when viewing products, and this address is used throughout the cart and checkout flow.
18
+
19
+ ### Automatic Address Prompting
20
+
21
+ When a user tries to add a product to cart without setting an address:
22
+
23
+ 1. Address input drawer opens automatically
24
+ 2. User enters their address
25
+ 3. Address is saved
26
+ 4. Add-to-cart action resumes automatically
27
+
28
+ No additional code needed - this is handled automatically.
29
+
30
+ ## Standalone Usage
31
+
32
+ Use the standalone address component when you need a dedicated address selection page:
33
+
34
+ ```javascript
35
+ const client = await Elements('YOUR_API_KEY', { env: 'production' });
36
+
37
+ await client.injectAddressElement('address-container');
38
+
39
+ // React to address selection by listening for the address_updated event
40
+ window.addEventListener('lce:actions.address_updated', (event) => {
41
+ console.log('Address set:', event.detail.data);
42
+ });
43
+ ```
44
+
45
+ ```html
46
+ <div id="address-container"></div>
47
+ ```
48
+
49
+ ## Address Actions
50
+
51
+ ### Set Address via Google Places ID
52
+
53
+ The recommended method - provides accurate geocoding:
54
+
55
+ ```javascript
56
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
57
+ ```
58
+
59
+ **How to get a Places ID:**
60
+
61
+ Visit [Google Place IDs](https://developers.google.com/maps/documentation/places/web-service/place-id#find-id) for details on obtaining a Places ID.
62
+
63
+ ### Set Address Manually
64
+
65
+ For custom address flows without Google Places:
66
+
67
+ ```javascript
68
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(
69
+ {
70
+ one: '123 Main Street',
71
+ two: 'Apt 4', // Optional at runtime
72
+ city: 'New York',
73
+ state: 'NY',
74
+ zip: '10001',
75
+ country: 'US'
76
+ },
77
+ {
78
+ latitude: 40.7128,
79
+ longitude: -74.0060
80
+ }
81
+ );
82
+ ```
83
+
84
+ **Requirements:**
85
+ - `one`: Street address (required)
86
+ - `two`: Apartment, suite, etc. (optional)
87
+ - `city`: City name (required)
88
+ - `state`: Two-letter state code (required)
89
+ - `zip`: ZIP/postal code (required)
90
+ - `country`: Country code, e.g. `'US'` (required by the `IAddressAddress` type)
91
+ - `latitude`: Number between -90 and 90 (required)
92
+ - `longitude`: Number between -180 and 180 (required)
93
+
94
+ ### Get Address Details
95
+
96
+ Retrieve the current address:
97
+
98
+ ```javascript
99
+ const addressData = window.LiquidCommerce.elements.actions.address.getDetails();
100
+
101
+ console.log(addressData);
102
+ // {
103
+ // id: 'ChIJ...',
104
+ // address: {
105
+ // one: '123 Main Street',
106
+ // two: 'Apt 4',
107
+ // city: 'New York',
108
+ // state: 'NY',
109
+ // zip: '10001',
110
+ // country: 'US'
111
+ // },
112
+ // coordinates: {
113
+ // latitude: 40.7128,
114
+ // longitude: -74.0060
115
+ // },
116
+ // formattedAddress: '123 Main Street, Apt 4, New York, NY 10001'
117
+ // }
118
+
119
+ // Returns null if no address is set
120
+ ```
121
+
122
+ ### Clear Address
123
+
124
+ Remove the current address:
125
+
126
+ ```javascript
127
+ await window.LiquidCommerce.elements.actions.address.clear();
128
+ ```
129
+
130
+ This will:
131
+ - Clear stored address
132
+ - Trigger address prompts on next cart action
133
+ - Update all components that depend on location
134
+
135
+ ## Events
136
+
137
+ ### Address Updated
138
+
139
+ Fired when a new address is set:
140
+
141
+ ```javascript
142
+ window.addEventListener('lce:actions.address_updated', (event) => {
143
+ const { address, coordinates, formattedAddress } = event.detail.data;
144
+
145
+ console.log('New address:', formattedAddress);
146
+ console.log('Coordinates:', coordinates);
147
+ });
148
+ ```
149
+
150
+ ### Address Cleared
151
+
152
+ Fired when address is removed:
153
+
154
+ ```javascript
155
+ window.addEventListener('lce:actions.address_cleared', (event) => {
156
+ console.log('Address has been cleared');
157
+ });
158
+ ```
159
+
160
+ ### Address Failed
161
+
162
+ Fired when address setting fails:
163
+
164
+ ```javascript
165
+ window.addEventListener('lce:actions.address_failed', (event) => {
166
+ const { error } = event.detail.data;
167
+ console.error('Address error:', error);
168
+ });
169
+ ```
170
+
171
+ ## Customization
172
+
173
+ ### Theme Configuration
174
+
175
+ Customize address component appearance:
176
+
177
+ ```javascript
178
+ const client = await Elements('YOUR_API_KEY', {
179
+ env: 'production',
180
+ customTheme: {
181
+ address: {
182
+ theme: {
183
+ backgroundColor: '#ffffff'
184
+ }
185
+ }
186
+ }
187
+ });
188
+ ```
189
+
190
+ ## Use Cases
191
+
192
+ ### Dedicated Location Page
193
+
194
+ Create a dedicated page for address selection:
195
+
196
+ ```html
197
+ <!DOCTYPE html>
198
+ <html>
199
+ <head>
200
+ <title>Set Delivery Location</title>
201
+ <script
202
+ defer
203
+ data-liquid-commerce-elements
204
+ data-token="YOUR_API_KEY"
205
+ data-env="production"
206
+ type="text/javascript"
207
+ src="https://elements.reservebar-worker.workers.dev/all/elements.js"
208
+ ></script>
209
+ </head>
210
+ <body>
211
+ <h1>Where should we deliver?</h1>
212
+ <div id="address"></div>
213
+
214
+ <script>
215
+ window.addEventListener('lce:actions.client_ready', async () => {
216
+ await window.LiquidCommerce.elements.injectAddressElement('address');
217
+ });
218
+
219
+ window.addEventListener('lce:actions.address_updated', () => {
220
+ // Redirect to product page after address is set
221
+ window.location.href = '/products';
222
+ });
223
+ </script>
224
+ </body>
225
+ </html>
226
+ ```
227
+
228
+ ### Custom Address Input with Validation
229
+
230
+ ```javascript
231
+ document.getElementById('save-address-btn').addEventListener('click', async () => {
232
+ const address = {
233
+ one: document.getElementById('street').value,
234
+ two: document.getElementById('apt').value,
235
+ city: document.getElementById('city').value,
236
+ state: document.getElementById('state').value,
237
+ zip: document.getElementById('zip').value
238
+ };
239
+
240
+ // Get coordinates from your geocoding service
241
+ const coords = await geocodeAddress(address);
242
+
243
+ try {
244
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
245
+ showSuccessMessage('Address saved!');
246
+ } catch (error) {
247
+ showErrorMessage('Invalid address');
248
+ }
249
+ });
250
+ ```
251
+
252
+ ### Pre-fill Address from User Account
253
+
254
+ ```javascript
255
+ // After user logs in, set their saved address
256
+ window.addEventListener('lce:actions.client_ready', async () => {
257
+ if (userIsLoggedIn && !currentAddressSet) {
258
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(
259
+ user.savedAddress,
260
+ user.savedCoordinates
261
+ );
262
+ }
263
+ });
264
+ ```
265
+
266
+ ### Location-Based Product Filtering
267
+
268
+ ```javascript
269
+ window.addEventListener('lce:actions.address_updated', async (event) => {
270
+ const { coordinates } = event.detail.data;
271
+
272
+ // Fetch products available in this location
273
+ const availableProducts = await fetch('/api/products', {
274
+ method: 'POST',
275
+ body: JSON.stringify({ latitude: coordinates.latitude, longitude: coordinates.longitude })
276
+ }).then(r => r.json());
277
+
278
+ // Update UI with available products
279
+ displayProducts(availableProducts);
280
+ });
281
+ ```
282
+
283
+ ### Multi-Location Switcher
284
+
285
+ ```javascript
286
+ const locations = [
287
+ { name: 'Home', placesId: 'ChIJ...' },
288
+ { name: 'Work', placesId: 'ChIJ...' },
289
+ { name: 'Mom\'s House', placesId: 'ChIJ...' }
290
+ ];
291
+
292
+ document.getElementById('location-select').addEventListener('change', async (e) => {
293
+ const selectedLocation = locations[e.target.value];
294
+
295
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(
296
+ selectedLocation.placesId
297
+ );
298
+
299
+ showNotification(`Switched to ${selectedLocation.name}`);
300
+ });
301
+ ```
302
+
303
+ ## Address Persistence
304
+
305
+ ### Storage
306
+
307
+ Addresses are stored in:
308
+ - SDK internal store
309
+ - LocalStorage (for persistence)
310
+ - Session (until explicitly cleared)
311
+
312
+ ### Lifespan
313
+
314
+ Addresses persist:
315
+ - Across page refreshes
316
+ - Across browser sessions
317
+ - Until explicitly cleared by user or code
318
+
319
+ ### Privacy
320
+
321
+ Addresses are:
322
+ - Stored locally in the browser
323
+ - Sent to LiquidCommerce servers for availability/product loading; the address id (with the cart id) may also be persisted server-side as a session fallback when localStorage is unavailable (and a delete request is sent when the address is cleared)
324
+ - Cleared when user logs out (if you implement logout handling)
325
+
326
+ ## Best Practices
327
+
328
+ ### Request Early
329
+
330
+ Set address as early as possible in the user flow:
331
+
332
+ ```javascript
333
+ // On homepage or landing page
334
+ window.addEventListener('lce:actions.client_ready', () => {
335
+ const currentAddress = window.LiquidCommerce.elements.actions.address.getDetails();
336
+
337
+ if (!currentAddress) {
338
+ // Show address prompt
339
+ showAddressPrompt();
340
+ }
341
+ });
342
+ ```
343
+
344
+ ### Provide Context
345
+
346
+ Explain why you need the address:
347
+
348
+ ```html
349
+ <div class="address-explainer">
350
+ <h2>Where should we deliver?</h2>
351
+ <p>We need your location to show available products and accurate pricing.</p>
352
+ <div id="address"></div>
353
+ </div>
354
+ ```
355
+
356
+ ### Validate Manually Entered Addresses
357
+
358
+ When using manual address entry, validate before setting:
359
+
360
+ ```javascript
361
+ async function setAddress(address, coords) {
362
+ // Validate format
363
+ if (!address.one || !address.city || !address.state || !address.zip) {
364
+ throw new Error('Missing required address fields');
365
+ }
366
+
367
+ // Validate state code
368
+ if (address.state.length !== 2) {
369
+ throw new Error('State must be 2-letter code');
370
+ }
371
+
372
+ // Validate ZIP
373
+ if (!/^\d{5}(-\d{4})?$/.test(address.zip)) {
374
+ throw new Error('Invalid ZIP code');
375
+ }
376
+
377
+ // Validate coordinates
378
+ if (coords.latitude < -90 || coords.latitude > 90) {
379
+ throw new Error('Invalid latitude');
380
+ }
381
+
382
+ if (coords.longitude < -180 || coords.longitude > 180) {
383
+ throw new Error('Invalid longitude');
384
+ }
385
+
386
+ // Set address
387
+ await window.LiquidCommerce.elements.actions.address.setAddressManually(address, coords);
388
+ }
389
+ ```
390
+
391
+ ### Handle Errors Gracefully
392
+
393
+ ```javascript
394
+ try {
395
+ await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId(placesId);
396
+ } catch (error) {
397
+ console.error('Failed to set address:', error);
398
+
399
+ // Show user-friendly error
400
+ showError('Unable to set that address. Please try again or enter manually.');
401
+
402
+ // Fall back to manual entry
403
+ showManualAddressForm();
404
+ }
405
+ ```
406
+ ## Troubleshooting
407
+
408
+ ### Address Not Persisting
409
+
410
+ 1. Check localStorage is not disabled
411
+ 2. Verify no errors in console
412
+ 3. Ensure `clear()` is not being called unintentionally
413
+ 4. Check that address was set successfully (no errors thrown)
414
+
415
+ ### Products Not Updating After Address Change
416
+
417
+ 1. Products should automatically rerender when address changes
418
+ 2. Check console for errors
419
+ 3. Verify address was actually set (not just input changed)
420
+ 4. Try manually rerendering product components
421
+
422
+ ### Invalid Address Errors
423
+
424
+ 1. Ensure all required fields are provided
425
+ 2. Verify coordinates are within valid ranges
426
+ 3. Check state code is 2 letters
427
+ 4. Validate ZIP code format
428
+ 5. Use Places ID method for most accurate results
429
+
430
+ ## See Also
431
+
432
+ - [Product Component](./product-component.md) - Uses address for availability
433
+ - [Cart Component](./cart-component.md) - Requires address for adding items
434
+ - [Actions API](../api/actions/address-actions.md) - Address actions reference
435
+ - [Events](./events.md) - All available events