I suggest using the forEachItem function to loop through all of the repeater’s items and sum up the total. You can then show that total in an element outside the repeater.
$w.onReady(() => {
let user = wixUsers.currentUser;
let userId = user.id;
wixData.query("Cart")
.eq("userId",userId)
.find()
.then((results) => {
$w("#dataset1").setFilter( wixData.filter()
.eq("userId",userId) );
});
wixData.query("Cart")
.eq("userId",userId)
.find()
.then( (results) => {
let items = results.items;
items.forEach((item) => { //did the forEach as you said
sum = (item.gtotal);
$w("#cgtotal").text = String(sum); //total should be displayed here
});
})