How to get woocommerce cart content without an action?

Not tested, but what if you use

WC()->cart->get_cart()

to retrieve the cart contents instead of the global $woocommerce object?

However, I believe the problem is that cart contents require the user’s session, and accessing it via cron won’t know who the user is. You might need to start querying the database directly through $wpdb in order to find this information outside of a specific user session.

error code: 523