I am trying to access the total weight of an order in my Checkout UI Extension. Currently utilizing Javascript (React).
Doesn’t appear to be a way to do this easily without querying each line item.
There used to be a useOrder()
we could utilize to easily get total order weight:
const order = useOrder();
order.lineItems.forEach(item => {
totalWeight += item.weight * item.quantity;
});
This appears to possibly be deprecated though I couldn’t find proof of this?
I have tried to get total weight via the useCartLines()
:
const totalWeight = cartLines.reduce((sum, line) => {
const lineWeight = line.merchandise.weight?.value || 0;
console.log('Line weight debug:', { productId: line.merchandise.product?.id, variantId: line.merchandise.id, weightValue: lineWeight, unit: line.merchandise.weight?.unit || 'none' });
return sum + (lineWeight * line.quantity);
}, 0) / 1000; // In kg
However there is no merchandise.weight
nor weight
anywhere I found within useCartLines()
.
API Version I am using is latest at time of post 2025-07
.
Any help would be appreciated, thank you.