the next function should tell me if current user is on "premium" plan not. I tried to test it but I can't in preview mode.
So I signed up as a real user but something isn't working and I can't debug it...
any ideas how to test if a user's premium plan is working?
$w.onReady(function () {
// check if user has a pricing Plan
let user = wixUsers.currentUser;
let planName;
user.getPricingPlans()
.then((pricingPlans) => {
let userPlan = pricingPlans[0];
planName = userPlan.name;
});
if (planName === undefined) {
// show at least 2-days-old results
var today = new Date().getTime(); // date in milliseconds
var twoDaysAgo = new Date(today - (2 * 24 * 60 * 60 * 1000));
$w("#dataset1").setFilter(wixData.filter()
.lt("_updatedDate", twoDaysAgo) // remove latest results
.eq("isApproved", true)); // show only approved data
console.log("user is: " + user.role);
console.log("user plan is: " + planName);
}
else if (planName === "Premium"){
$w("#textConnectedAsPremium").show(); // not working in real user
$w("#dataset1").setFilter(wixData.filter()
.eq("isApproved", true)); // show only approved data
console.log(planName); // can't see it anywhere
}
// the rest of the code here...
}