Actions

Actions let you control Elements programmatically after the SDK initializes. All actions live under window.elements.actions.*.

Quick start

window.addEventListener('lce:actions.client_ready', () => {
  window.elements.actions.cart.openCart();
});

Product actions

actions.product.getDetails(identifier)

Returns the current loaded product data (price, size, fulfillment, retailer, quantity, images, and more). The product must already be injected and loaded.

Example

const product = window.elements.actions.product.getDetails('00619947000020');
console.log(product.name, product.price / 100);

Cart actions

actions.cart.openCart()

Opens the cart drawer.

Example

actions.cart.closeCart()

Closes the cart drawer.

Example

actions.cart.toggleCart()

Toggles the cart drawer open/closed.

Example

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.

Example

actions.cart.applyPromoCode(promoCode)

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

Example

actions.cart.removePromoCode()

Removes the active promo code.

Example

actions.cart.resetCart()

Clears all cart items (no undo).

Example

actions.cart.getDetails()

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

Example

Checkout actions

actions.checkout.openCheckout()

Opens the checkout drawer or navigates to checkout.

Example

actions.checkout.closeCheckout()

Closes the checkout drawer.

Example

actions.checkout.toggleCheckout()

Toggles the checkout drawer open/closed.

Example

actions.checkout.exitCheckout()

Navigates away from checkout (requires exitUrl configuration).

Example

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

Adds products directly to checkout (bypasses cart).

Example

actions.checkout.applyPromoCode(promoCode)

Applies a promo code in checkout.

Example

actions.checkout.removePromoCode()

Removes the active promo code in checkout.

Example

actions.checkout.applyGiftCard(code)

Applies a gift card.

Example

actions.checkout.removeGiftCard(code)

Removes a gift card.

Example

actions.checkout.toggleIsGift(active?)

Enables/disables gift mode (toggles when omitted).

Example

actions.checkout.toggleBillingSameAsShipping(active?)

Sets whether billing address matches shipping.

Example

actions.checkout.toggleMarketingPreferences(field, active)

Sets marketing opt-in (canEmail or canSms).

Example

actions.checkout.updateCustomerInfo(fields)

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

Example

actions.checkout.updateBillingInfo(fields)

Prefills billing address fields.

Example

actions.checkout.updateGiftInfo(fields)

Prefills gift recipient information.

Example

actions.checkout.getDetails()

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

Example

Address actions

actions.address.setAddressByPlacesId(placesId)

Sets address using a Google Places ID (recommended).

Example

actions.address.setAddressManually(address, coordinates)

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

Example

actions.address.getDetails()

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

Example

actions.address.clear()

Removes the stored address and resets availability.

Example

UI helpers (non-actions)

These helpers live under window.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.