Get cart item measurement

Use the shared storefront runtime to read normalized Measura measurements from Shopify cart line items.

window.Measura.getCartItemMeasurementByKey(lineItemKey, options?)

Looks up a cart line item by Shopify line item key and returns its normalized Measura measurement.

Availability

  • Available when the shared Measura storefront runtime is loaded.
  • Does not require a mounted Measura product block.
  • Uses options.cart when provided, otherwise falls back to window.MeasuraCart when available.

Input

lineItemKey: string | number

options?: {
  cart?: {
    items?: Array<{
      key?: string | number;
      properties?: Record<string, any>;
    }>;
  };
}

Output

{
  measurement: {
    type: "weight" | "length" | "area" | "volume" | "time";
    value: number;
    unit: string;
    dimensions: Array<{
      value: number;
      unit: string;
    }>;
  };
} | null

Behavior

  • Returns null when the key is missing, the item is not found, or the item is not a Measura item.

Example

const result = window.Measura.getCartItemMeasurementByKey("794df6e3f3c4f4b1f9e9f3b7f7b1b2c4", {
  cart
});