Can't get cart details in snipcart.ready event

Hi there. I have some code I’m adding in the snipcart.ready browser event to get the product IDs of each item in the cart, but it doesn’t retrieve any data.

Currently, I have the following code:

document.addEventListener('snipcart.ready', function() {

Just to simply start by retrieving the number of the items in the cart (2 different ways just to test) and the cart total, but they all return a value of 0. If I paste any of these individual methods into the JS console after the page has fully loaded, then it retrieves the correct values. I suspect that somehow the snipcart.ready event is firing before the cart details have actually been loaded, but I have no idea how to fix it if that’s the case.

I’m using the latest version of Snipcart and have even tried triggering window.LoadSnipcart() before the event handling, and have tried placing the snipcart.ready event listener before or after loading Snipcart, but to no avail.

Any help would be greatly appreciated.