> For the complete documentation index, see [llms.txt](https://docs.liquidcommerce.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liquidcommerce.cloud/elements-v2/actions.md). Agents can also search and read this documentation through its [MCP server](https://docs.liquidcommerce.cloud/~gitbook/mcp).

# Actions

Actions let you control Elements programmatically after the SDK initializes. On the full `Elements()` client, actions live under `window.LiquidCommerce.elements.actions.*`. The checkout-only client exposes its supported checkout actions under `window.LiquidCommerce.elementsCheckout.actions.checkout.*`.

## Quick start

```js
window.addEventListener('lce:actions.client_ready', () => {
  window.LiquidCommerce.elements.actions.cart.openCart();
}, { once: true });
```

## Product actions

### `actions.product.getDetails(identifier)`

Returns the current loaded product data (identifier, sizes, selected size and fulfillment, availability, priceInfo, images, and more). The product must already be injected and loaded.

**Signature**

```ts
getDetails(identifier: string): IBaseProductEventData
```

**Return shape (TypeScript)**

```ts
export type FulfillmentType = 'onDemand' | 'shipping';

export interface IProductPriceInfo {
  currency: string;
  minimum: number;
  average: number;
  maximum: number;
}

export interface IBaseProductEventData {
  identifier: string;
  selectedSizeId: string | null;
  selectedFulfillmentType: FulfillmentType;
  selectedFulfillmentId: string | null;
  productHasAvailability: boolean;
  fulfillmentHasAvailability: boolean;
  sizes: Record<string, IProductSizeEventData>;

  id: string;
  name: string;
  description: string;
  htmlDescription: string;
  images: string[];
  brand: string;
  region: string;
  country: string;
  material: string;
  abv: string;
  proof: string;
  age: string;
  color: string;
  flavor: string;
  variety: string;
  appellation: string;
  vintage: string;
  tastingNotes: string;
  catPath: string;
  category: string;
  classification: string;
  type: string;
  subType: string;
  salsifyGrouping: string;
  priceInfo: IProductPriceInfo | null;
}

export interface IProductSizeEventData {
  id: string;
  upc: string;
  size: string;
  pack: boolean;
  packDesc: string;
  container: string;
  containerType: string;
  image: string;
  uom: string;
  volume: string;
  maxQuantityPerOrder: number;
  attributes: IProductSizeAttributes;
  onDemandFulfillments: Record<string, IProductFulfillmentEventData>;
  shippingFulfillments: Record<string, IProductFulfillmentEventData>;
}

export interface IProductSizeAttributes {
  presale: IProductPresale;
  engraving: IProductSizeEngraving;
}

export interface IProductSizeEngraving {
  maxLines: number;
  maxCharsPerLine: number;
  fee: number;
  location: string;
  isRequired: boolean;
}

export interface IProductPresale {
  canPurchaseOn: string | null;
  estimatedShipBy: string | null;
  isActive: boolean;
  language: string;
}

export interface IProductFulfillmentEventData {
  id: string;
  type: FulfillmentType;
  doesAllowGiftCards: boolean;
  doesAllowPromos: boolean;
  expectation: string;
  engravingExpectation: string;
  fee: number;
  timezone: string;
  hourStatus: IProductFulfillmentHourStatus;
  retailerName: string;
  retailerAddress: IRetailerAddress;
  retailerAddressFormatted: string;
  variant: IProductVariant;
}

export interface IProductFulfillmentHourStatus {
  isOpen: boolean;
  openTime: string;
  isClosed: boolean;
  closeTime: string;
}

export interface IProductVariant {
  retailerId: string;
  shippingFulfillmentId: string;
  onDemandFulfillmentId: string;
  isEngravable: boolean;
  partNumber: string;
  price: number;
  stock: number;
}

export type IRetailerAddress = IAddressAddress & IAddressCoordinates;

export interface IAddressAddress {
  one: string;
  two: string;
  city: string;
  state: string;
  zip: string;
  country: string;
}

export interface IAddressCoordinates {
  latitude: number;
  longitude: number;
}
```

**Example**

```js
const product = window.LiquidCommerce.elements.actions.product.getDetails('00619947000020');
console.log(product.name, product.priceInfo?.average / 100);
```

### `actions.product.getProductAvailabilityByState(identifiers, state?)`

Check product availability across states.

**Signature**

```ts
getProductAvailabilityByState(identifiers: string[], state?: string): Promise<IProductAvailabilityResponse>
```

**Example**

```js
const availability = await window.LiquidCommerce.elements.actions.product
  .getProductAvailabilityByState(['00619947000020'], 'CA');
```

## Cart actions

### `actions.cart.openCart()`

Opens the cart drawer.

**Signature**

```ts
openCart(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.cart.openCart();
```

### `actions.cart.closeCart()`

Closes the cart drawer.

**Signature**

```ts
closeCart(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.cart.closeCart();
```

### `actions.cart.toggleCart()`

Toggles the cart drawer open/closed.

**Signature**

```ts
toggleCart(): void
```

**Example**

```js
document.getElementById('cart-btn').addEventListener('click', () => {
  window.LiquidCommerce.elements.actions.cart.toggleCart();
});
```

### `actions.cart.addProduct(params[], openCart?)`

Adds one or more products to the cart. If no address is set, the SDK prompts for one and retries automatically.

**Signature**

```ts
addProduct(params: IAddProductParams[], openCart?: boolean): Promise<void>
```

**Parameters (TypeScript)**

```ts
export type FulfillmentType = 'onDemand' | 'shipping';

export interface IAddProductParams {
  identifier: string;
  fulfillmentType: FulfillmentType;
  quantity: number;
  engravingLines?: string[];
}
```

**`engravingLines` (optional)**

Pre-fills an engraving for the added item. The SDK enforces the product's engraving rules and will silently degrade rather than fail the add-to-cart:

* If the value is not an array of strings, it's ignored (warning logged).
* Blank/whitespace-only entries are stripped; an empty result is treated as no engraving.
* If the product (or its size) does not support engraving, lines are dropped and the item is added without engraving.
* Lines beyond `maxLines` are truncated; any line longer than `maxCharsPerLine` is truncated to that length.
* If no engravable variant is available for the requested fulfillment, lines are dropped and the item is still added.

**Example**

```js
await window.LiquidCommerce.elements.actions.cart.addProduct([
  { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 },
  { identifier: '08504405135', fulfillmentType: 'onDemand', quantity: 2 },
  {
    identifier: '00619947000020',
    fulfillmentType: 'shipping',
    quantity: 1,
    engravingLines: ['Happy Birthday', 'Love, Sam']
  }
], true);
```

### `actions.cart.applyPromoCode(promoCode)`

Applies a promo code to the cart (replaces any existing code).

**Signature**

```ts
applyPromoCode(promoCode: string): Promise<void>
```

**Example**

```js
// An invalid or nonexistent code does NOT reject the promise —
// it resolves normally and is reported via this event.
window.addEventListener('lce:actions.cart_promo_code_failed', (e) => {
  console.error('Promo code invalid:', e.detail.data.error);
});

try {
  await window.LiquidCommerce.elements.actions.cart.applyPromoCode('SUMMER20');
} catch (error) {
  // Only fires on a hard request/network failure.
  console.error('Promo code request failed:', error);
}
```

> Blank promo codes resolve without throwing, set `cart.error`, and do not emit a promo-code event. You can also confirm successful outcomes by inspecting `actions.cart.getDetails()`.

### `actions.cart.removePromoCode()`

Removes the active promo code.

**Signature**

```ts
removePromoCode(): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.cart.removePromoCode();
```

### `actions.cart.resetCart()`

Clears all cart items (no undo).

**Signature**

```ts
resetCart(): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.cart.resetCart();
```

### `actions.cart.getDetails()`

Returns current cart data (items, totals, promo, retailers, location, etc.).

**Signature**

```ts
getDetails(): IBaseCartEventData
```

**Return shape (TypeScript)**

```ts
export type FulfillmentType = 'onDemand' | 'shipping';

export interface IBaseCartEventData {
  cartId: string;
  promoCodeDiscount: number | null;
  subtotal: number;
  itemCount: number;
  items: Record<string, ICartItem>;
  retailers: Record<string, ICartRetailer>;
  location: {
    placesId: string;
    formattedAddress: string;
    address: IAddressAddress;
    coordinates: IAddressCoordinates;
  } | null;
}

export interface ICartItem {
  id: string;
  variantId: string;
  liquidId: string;
  retailerId: string;
  partNumber: string;
  fulfillmentId: string;
  upc: string;
  sku: string;
  salsifyGrouping: string;
  catPath: string;
  volume: string;
  uom: string;
  pack: boolean;
  packDesc: string;
  container: string;
  containerType: string;
  name: string;
  brand: string;
  size: string;
  price: number;
  quantity: number;
  maxQuantity: number;
  unitPrice: number;
  mainImage: string;
  attributes: ICartItemAttributes;
}

export interface ICartItemAttributes {
  engraving: ICartItemEngraving;
  presale: IProductPresale;
}

export interface ICartItemEngraving {
  isEngravable: boolean;
  isRequired: boolean;
  hasEngraving: boolean;
  fee: number;
  maxCharsPerLine: number;
  maxLines: number;
  location: string;
  lines: string[];
}

export interface IProductPresale {
  canPurchaseOn: string | null;
  estimatedShipBy: string | null;
  isActive: boolean;
  language: string;
}

export interface ICartRetailer {
  id: string;
  name: string;
  subtotal: number;
  itemsQuantity: number;
  fulfillments: Record<string, ICartFulfillment>;
}

export interface ICartFulfillment {
  id: string;
  canEngrave: boolean;
  type: FulfillmentType;
  expectation: string;
  engravingExpectation: string;
  itemIds: string[];
  subtotal: number;
  hasUnmetMinimumPurchaseAmount: boolean;
  minimumPurchaseAmount: number;
}

export interface IAddressAddress {
  one: string;
  two: string;
  city: string;
  state: string;
  zip: string;
  country: string;
}

export interface IAddressCoordinates {
  latitude: number;
  longitude: number;
}
```

**Example**

```js
const cart = window.LiquidCommerce.elements.actions.cart.getDetails();
console.log(cart.cartId, cart.itemCount, cart.subtotal / 100);
```

## Checkout actions

> **Note:** The three drawer-navigation actions below (`openCheckout`, `closeCheckout`, `toggleCheckout`) are only available on the full `Elements()` client. They are **not** available on the checkout-only client (`window.LiquidCommerce.elementsCheckout`), whose `actions.checkout` is typed as `IElementsCheckoutActions` and omits them.

### `actions.checkout.openCheckout()`

Opens the checkout drawer. (This action always opens the in-page checkout drawer — it does not perform the hosted-checkout redirect that `checkout.pageUrl` configures; that redirect only happens internally via the cart's own "Proceed to Checkout" button and after a presale add-to-cart.)

**Signature**

```ts
openCheckout(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.openCheckout();
```

### `actions.checkout.closeCheckout()`

Closes the checkout drawer.

**Signature**

```ts
closeCheckout(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.closeCheckout();
```

### `actions.checkout.toggleCheckout()`

Toggles the checkout drawer open/closed.

**Signature**

```ts
toggleCheckout(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.toggleCheckout();
```

### `actions.checkout.exitCheckout()`

Navigates away from checkout (requires `exitUrl` configuration).

**Signature**

```ts
exitCheckout(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.exitCheckout();
```

### `actions.checkout.addProduct(params[], openCheckout?)`

Adds products to the cart, then loads (and optionally opens) checkout in a single call. For a flow that skips the cart session entirely, use [`actions.checkout.addAnonymousProduct`](#actionscheckoutaddanonymousproductparams).

> **Note:** This behaves differently depending on the client. On the full `Elements()` client, `addProduct` delegates to `actions.cart.addProduct`: if no address is set yet, it opens the address-input drawer and retries automatically once an address is provided. On the checkout-only client (`window.LiquidCommerce.elementsCheckout`), which exposes no `actions.address` namespace and no drawer navigation, an address/location must already be resolved in the session before this call — otherwise it throws `SDKError('Location is required to add products to checkout')`.

**Signature**

```ts
addProduct(params: IAddProductParams[], openCheckout?: boolean): Promise<void>
```

**Parameters (TypeScript)**

```ts
export type FulfillmentType = 'onDemand' | 'shipping';

export interface IAddProductParams {
  identifier: string;
  fulfillmentType: FulfillmentType;
  quantity: number;
  engravingLines?: string[];
}
```

**`engravingLines` (optional)**

Same behavior as `actions.cart.addProduct`: invalid input is ignored, blanks are stripped, lines are clamped to the product's `maxLines` / `maxCharsPerLine`, and engraving is dropped (without failing the call) if the product, variant, or fulfillment doesn't support it.

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.addProduct([
  {
    identifier: '00619947000020',
    fulfillmentType: 'shipping',
    quantity: 1,
    engravingLines: ['For Dad']
  }
], true);
```

### `actions.checkout.applyPromoCode(promoCode)`

Applies a promo code in checkout.

**Signature**

```ts
applyPromoCode(promoCode: string): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.applyPromoCode('WELCOME10');
```

### `actions.checkout.removePromoCode()`

Removes the active promo code in checkout.

**Signature**

```ts
removePromoCode(): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.removePromoCode();
```

### `actions.checkout.applyGiftCard(code)`

Applies a gift card.

**Signature**

```ts
applyGiftCard(code: string): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.applyGiftCard('GIFT-1234-5678-9012');
```

### `actions.checkout.removeGiftCard(code)`

Removes a gift card.

**Signature**

```ts
removeGiftCard(code: string): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.removeGiftCard('GIFT-1234-5678-9012');
```

### `actions.checkout.toggleIsGift(active?)`

Enables/disables gift mode (toggles when omitted).

**Signature**

```ts
toggleIsGift(active?: boolean): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.toggleIsGift(true);
```

### `actions.checkout.toggleBillingSameAsShipping(active?)`

Sets whether billing address matches shipping.

**Signature**

```ts
toggleBillingSameAsShipping(active?: boolean): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.toggleBillingSameAsShipping(false);
```

### `actions.checkout.toggleMarketingPreferences(field, active)`

Sets marketing opt-in (`canEmail` or `canSms`).

**Signature**

```ts
toggleMarketingPreferences(field: 'canEmail' | 'canSms', active: boolean): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.checkout.toggleMarketingPreferences('canEmail', true);
```

### `actions.checkout.updateCustomerInfo(fields)`

Prefills customer info (name, email, phone, birthDate, etc.).

**Signature**

```ts
updateCustomerInfo(params: Record<CustomerFieldName, string>): void
```

**Parameters (TypeScript)**

```ts
export type CustomerFieldName =
  | 'firstName'
  | 'lastName'
  | 'email'
  | 'phone'
  | 'birthDate'
  | 'addressTwo'
  | 'company';
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.updateCustomerInfo({
  firstName: 'John',
  lastName: 'Doe',
  email: 'john@example.com',
  phone: '+15551234567'
});
```

### `actions.checkout.updateBillingInfo(fields)`

Prefills billing address fields.

**Signature**

```ts
updateBillingInfo(params: Record<BillingFieldName, string>): void
```

**Parameters (TypeScript)**

```ts
export type BillingFieldName =
  | 'firstName'
  | 'lastName'
  | 'email'
  | 'phone'
  | 'company'
  | 'addressOne'
  | 'addressTwo'
  | 'city'
  | 'state'
  | 'zipCode';
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.updateBillingInfo({
  firstName: 'John',
  lastName: 'Doe',
  addressOne: '789 Elm St',
  city: 'Chicago',
  state: 'IL',
  zipCode: '60601'
});
```

### `actions.checkout.updateGiftInfo(fields)`

Prefills gift recipient information.

**Signature**

```ts
updateGiftInfo(params: Record<GiftFieldName, string>): void
```

**Parameters (TypeScript)**

```ts
export type GiftFieldName =
  | 'firstName'
  | 'lastName'
  | 'email'
  | 'phone'
  | 'addressTwo'
  | 'message';
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
  firstName: 'Jane',
  lastName: 'Smith',
  message: 'Happy Birthday!'
});
```

### `actions.checkout.setSavedPaymentMethod(params)`

Pre-selects a saved payment method. The payment step then shows a read-only card summary instead of the Stripe card form, and the order is placed without re-entering card details. `id` must be a payment method the backend holds for the checkout's customer; `card` is used to render the summary. If the backend does not recognize the `id`, saving the payment step fails and the order cannot be placed. It can be set before opening checkout or while it is open — the payment step updates automatically — and the selection persists across a cart reset within the session.

**Signature**

```ts
setSavedPaymentMethod(params: {
  id: string;
  card: { brand: string; last4: string; expMonth?: string | number; expYear?: string | number };
}): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.setSavedPaymentMethod({
  id: 'pm_123',
  card: { brand: 'Visa', last4: '4242', expMonth: '12', expYear: '30' }
});
```

### `actions.checkout.clearSavedPaymentMethod()`

Removes a previously set saved payment method, restoring the Stripe card-entry form.

**Signature**

```ts
clearSavedPaymentMethod(): void
```

**Example**

```js
window.LiquidCommerce.elements.actions.checkout.clearSavedPaymentMethod();
```

### `actions.checkout.getDetails()`

Returns current checkout data (amounts, items, preferences, addresses, gift info, etc.).

**Signature**

```ts
getDetails(): ICheckoutDetailsEventData
```

**Return shape (TypeScript)**

```ts
export interface ICheckoutDetailsEventData {
  token: string;
  cartId: string;
  isGift: boolean;
  billingSameAsShipping: boolean;
  marketingPreferences: ICheckoutMarketingPreferences;
  hasPromoCode: boolean;
  hasGiftCards: boolean;
  amounts: ICheckoutAmounts;
  itemCount: number;
  items: Record<string, ICheckoutItem>;
}

export interface ICheckoutMarketingPreferences {
  canEmail: boolean;
  canSms: boolean;
}

export interface ICheckoutAmounts {
  subtotal: number;
  engraving: number;
  service: number;
  shipping: number;
  delivery: number;
  platform: number;
  discounts: number;
  giftCards: number;
  tax: number;
  tip: number;
  total: number;
}

export interface ICheckoutItem {
  variantId: string;
  cartItemId: string;
  liquidId: string;
  retailerId: string;
  fulfillmentId: string;
  salsifyPid?: string;
  salsifyGrouping?: string;
  name: string;
  catPath: string;
  volume: string;
  uom: string;
  proof: string;
  abv: string;
  containerType: string;
  container: string;
  size: string;
  pack: boolean;
  packDesc: string;
  mainImage: string;
  brand: string;
  partNumber: string;
  upc: string;
  sku: string;
  price: number;
  unitPrice: number;
  quantity: number;
  tax: number;
  unitTax: number;
  bottleDeposits: number;
  attributes: ICheckoutItemAttributes;
}

export interface ICheckoutItemAttributes {
  engraving: ICheckoutItemEngraving;
  presale: IProductPresale;
}

export interface ICheckoutItemEngraving {
  isEngravable: boolean;
  isRequired: boolean;
  hasEngraving: boolean;
  fee: number;
  maxCharsPerLine: number;
  maxLines: number;
  location: string;
  lines: string[];
}

export interface IProductPresale {
  canPurchaseOn: string | null;
  estimatedShipBy: string | null;
  isActive: boolean;
  language: string;
}
```

**Example**

```js
const checkout = window.LiquidCommerce.elements.actions.checkout.getDetails();
console.log(checkout.cartId, checkout.amounts.total / 100);
```

### `actions.checkout.getProductAvailabilityByState(identifiers, state?)`

Check product availability across states from the checkout context.

**Signature**

```ts
getProductAvailabilityByState(identifiers: string[], state?: string): Promise<IProductAvailabilityResponse>
```

**Example**

```js
const availability = await window.LiquidCommerce.elements.actions.checkout
  .getProductAvailabilityByState(['00619947000020'], 'CA');
```

### `actions.checkout.addAnonymousProduct(params)`

Add a product to checkout without requiring a cart session. Used for direct-to-checkout flows.

**Signature**

```ts
addAnonymousProduct(params: IAnonymousCheckoutAddProductParams): Promise<IAnonymousCheckoutAddProductResponse>
```

**Parameters (`IAnonymousCheckoutAddProductParams`)**

| Field       | Type                                 | Required | Description                                                                                                                                   |
| ----------- | ------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `location`  | `ILocation`                          | Yes      | `{ address: IAddressAddress; coordinates: IAddressCoordinates }`                                                                              |
| `items`     | `IAnonymousCheckoutAddProductItem[]` | Yes      | Products to add: `{ identifier, fulfillmentType, quantity }`. Must be a non-empty array — this is the only field the SDK currently validates. |
| `cartItems` | `ICartUpdateItem[]`                  | No       | Declared on the type but not read or validated by the current SDK build — a `cartItems`-only call is rejected. Use `items` instead.           |
| `promoCode` | `string`                             | No       | Promo code applied while creating the anonymous checkout.                                                                                     |

**Return shape (TypeScript)**

```ts
export type FulfillmentType = 'onDemand' | 'shipping';

export interface IAnonymousCheckoutAddProductResponse {
  checkout: ICheckoutPrepare | null;
  unavailableItems: IAnonymousCheckoutUnavailableItem[];
}

export interface IAnonymousCheckoutUnavailableItem {
  identifier: string;
  productName: string | null;
  fulfillmentType: FulfillmentType;
  reason: 'product_not_available' | 'fulfillment_not_available';
}
```

**Example**

```js
const result = await window.LiquidCommerce.elements.actions.checkout
  .addAnonymousProduct({
    items: [
      { identifier: '00619947000020', fulfillmentType: 'shipping', quantity: 1 }
    ],
    location: {
      address: { one: '123 Main St', two: '', city: 'New York', state: 'NY', zip: '10001', country: 'US' },
      coordinates: { latitude: 40.7128, longitude: -74.006 }
    },
    promoCode: 'WELCOME10' // optional
  });

console.log(result.checkout?.token, result.unavailableItems);
```

## Address actions

### `actions.address.setAddressByPlacesId(placesId)`

Sets address using a Google Places ID (recommended).

**Signature**

```ts
setAddressByPlacesId(placesId: string): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.address.setAddressByPlacesId('ChIJOwg_06VPwokRYv534QaPC8g');
```

### `actions.address.setAddressManually(address, coordinates)`

Sets address with your own address + lat/long data.

**Signature**

```ts
setAddressManually(address: IAddressAddress, coordinates: IAddressCoordinates): Promise<void>
```

**Parameters (TypeScript)**

```ts
export interface IAddressAddress {
  one: string;
  two: string;
  city: string;
  state: string;
  zip: string;
  country: string;
}

export interface IAddressCoordinates {
  latitude: number;
  longitude: number;
}
```

**Example**

```js
await window.LiquidCommerce.elements.actions.address.setAddressManually(
  { one: '123 Main Street', two: '', city: 'New York', state: 'NY', zip: '10001', country: 'US' },
  { latitude: 40.7128, longitude: -74.0060 }
);
```

### `actions.address.getDetails()`

Returns the current address (or `null` if not set).

**Signature**

```ts
getDetails(): IAddressData | null
```

**Return shape (TypeScript)**

```ts
export interface IAddressData {
  id: string;
  formattedAddress: string;
  address: IAddressAddress;
  coordinates: IAddressCoordinates;
}

export interface IAddressAddress {
  one: string;
  two: string;
  city: string;
  state: string;
  zip: string;
  country: string;
}

export interface IAddressCoordinates {
  latitude: number;
  longitude: number;
}
```

**Example**

```js
const address = window.LiquidCommerce.elements.actions.address.getDetails();
console.log(address?.formattedAddress);
```

### `actions.address.clear()`

Removes the stored address, resets the cart, and clears any locally persisted address/cart state.

**Signature**

```ts
clear(): Promise<void>
```

**Example**

```js
await window.LiquidCommerce.elements.actions.address.clear();
```

## UI helpers (non-actions)

These helpers live under `window.LiquidCommerce.elements.ui.*` and are commonly used with actions.

* `ui.cartButton(containerId, showItemsCount?)` - Renders a cart button inside the given container.
* `ui.floatingCartButton(showItemsCount?)` - Renders a floating cart button (bottom-right).
* `ui.cartSubtotal(elementId)` - Keeps an element updated with cart subtotal.
* `ui.cartItemsCount(elementId, { hideZero })` - Keeps an element updated with cart item count.

```js
window.LiquidCommerce.elements.ui.cartButton('header-cart', true);
window.LiquidCommerce.elements.ui.floatingCartButton(true);
window.LiquidCommerce.elements.ui.cartSubtotal('cart-total');
window.LiquidCommerce.elements.ui.cartItemsCount('items-count', { hideZero: true });
```

***

**See also:** [Events](https://docs.liquidcommerce.cloud/elements-v2/events.md) — most actions emit a matching event you can listen for.
