Use the shared storefront runtime to build Measura-compatible line item properties from Shopify theme code.
These shared storefront methods are available as long as the Measura shared runtime is loaded.
window.Measura is loaded when at least one Measura app block or app embed is rendered on the page.
Both line item property methods are asynchronous. Theme code should await them.
await window.Measura.buildLineItemProperties({
productId: 9904458072362,
productHandle: "sample-product",
variantId: 50661130010922,
measurement: {
dimensions: [{ value: 1, unit: "lb" }]
}
});window.Measura.buildLineItemProperties(options)Builds Measura line item properties for a single line item.
Promise<Array<{ name: string; value: string }>>{
productId: string | number;
productHandle: string;
variantId: string | number;
measurement: {
dimensions?: Array<{
value: number | string;
unit: string;
}>;
};
baseProperties?:
| Record<string, string | number | boolean>
| Array<{ name: string; value: string | number | boolean }>;
includeDataFields?: boolean;
}window.AtomicPOS.Unit price and Net weight or Net length.baseProperties..measura-data-field inputs for the product when includeDataFields is not set to false._measura_data.[] whenproductId, productHandle, or variantId is missing.measurement.dimensions[0].value is missing or not a positive number.measurement.dimensions[0].unit is missing.const properties = await window.Measura.buildLineItemProperties({
productId: 9904458072362,
productHandle: "sample-backpack-4",
variantId: 50661130010922,
measurement: {
dimensions: [{ value: 1, unit: "lb" }]
},
baseProperties: {
Note: "Buy again"
}
});Example response:
[
{ name: "Unit price", value: "$12.00 / lb" },
{ name: "Net weight", value: "1 lb" },
{
name: "_measura_data",
value: "{\"properties\":{\"Note\":\"Buy again\"},\"measurement\":{\"type\":\"weight\",\"dimensions\":[{\"unit\":\"lb\",\"value\":1}]}}"
}
]window.Measura.buildLineItemPropertiesBulk(items)Builds Measura line item properties for multiple items.
Promise<Array<Array<{ name: string; value: string }>>>Array<{
productId: string | number;
productHandle: string;
variantId: string | number;
measurement: {
dimensions?: Array<{
value: number | string;
unit: string;
}>;
};
baseProperties?:
| Record<string, string | number | boolean>
| Array<{ name: string; value: string | number | boolean }>;
includeDataFields?: boolean;
}>[] for individual non-Measura products.items is not an array or if any item fails with an invalid-input or hydration error.const results = await window.Measura.buildLineItemPropertiesBulk([
{
productId: 9904458072362,
productHandle: "sample-backpack-4",
variantId: 50661130010922,
measurement: {
dimensions: [{ value: 1, unit: "lb" }]
}
},
{
productId: 1234567890,
productHandle: "non-measura-product",
variantId: 987654321,
measurement: {
dimensions: [{ value: 1, unit: "lb" }]
}
}
]);In this example
results[0] contains the built Measura properties.results[1] is [] if the second product is not Measura-enabled.measurement.type is not accepted by the public API. Measura uses the stored product measurement type and validates it against the provided dimension unit.productHandle is required on every call so the runtime can hydrate product state when needed._measura_data.When to use this:
Use these methods from Shopify theme code. If you are building an external system, mobile app, or custom checkout that cannot access the storefront runtime, follow the cart integration guide instead.