You have a number of issues with your code…
The variable curMemEmail is not available later in your code since it is only defined (and available) in the .then() function of currentMember . getMember ().
The same goes for the variable PlanCap which is only available in the .then() function of wixPaidPlans . getCurrentMemberOrders ().
The .then() function is triggered when the called function’s Promise is resolved. See the following for more information about Promises:
In your database query, you see to be mixing datasets and collections together. What is #EventsData? Is it a dataset or is it a database collection? If it is a collection, then you don’t need the .onReady() function, and you should be getting an error. If it’s a dataset, then wixDataQuery won’t work since wixDataQuery only works with collection.
If #EventsData is a collection, then you also have an error in your query:
.eq("Email","CurMemEmail")
The field key should be used and always starts with a lowercase letter. You should also be using a variable without quotes. Like this:
.eq("email",CurMemEmail)
Note: as I mentioned above, the variable CurMemEmail won’t be available here.
Refer to the documentation for Wix Data with Velo for more information.