In order to get cart information such as total cart price, items in the cart etc.. in a guest session in Sitecore CDP & Personalize, there is no cart object to use directly. Instead, ADD events in the session need to be aggregated until a CLEAR_CART event is reached.

Below is the code example that can be used in Audience Filters or Decision Models to get the total cart price.

if (entity && guest && guest.sessions) {
    var currentWebSession = null;
    // Find current session
    guest.sessions.forEach((session) => {
        if (session.sessionType === 'WEB' && session.ref == entity.sessionRef) {
            currentWebSession = session;
            return;
        }
    });
    if (currentWebSession !== null) {
        // Get cart price
        var cartPrice = 0;
        for (var i = 0; i < currentWebSession.events.length; i++) {
            var e = currentWebSession.events[i];
            if (e.type === "CLEAR_CART") {
                break;
            }
            if (e.type === "ADD" && e.arbitraryData && e.arbitraryData.product && e.arbitraryData.product.price && e.arbitraryData.product.quantity) {
                cartPrice = cartPrice + (e.arbitraryData.product.price * e.arbitraryData.product.quantity);
            }
        }
    }
}

Note: entity is normally the object that have the trigger entity information such as when triggered by a custom event etc...