Why am I getting inconsistent results with checkout.line_items in Liquid script?

Scooch
Shopify Partner
2 0 0

I am trying to collect data from the order status page via Liquid script but I am getting inconsistent results when accessing checkout.line_items

 

I added the code below to the order status page additional scripts section, and for some orders I get the correct amount of items, but for some I get 0. I can't find a pattern, but it's consistent between orders (once 0 always 0, once correct always correct). For some orders this prop exists, for some it doesn't.

 

Obviously all orders have items.

 

Can anyone shed some light please?

 

<script>
  console.log('checkout.line_items.size', {{checkout.line_items | size}});
</script>
 
Reply 1 (1)

Scooch
Shopify Partner
2 0 0

To complement, the whole checkout object seems to not be present. This line of code prints nothing:

 

console.log('checkout.id', {{checkout.id}});