I have two custom made membership areas and custom code collecting payments for paid plans. I would like to display to site members on their profile what plan they have paid for and how much time remains before they need to renew their subscription which operates over a 3 month period. This is the code I have so far but it doesn’t seem to be working and console isn’t logging errors about it.
import wixPaidPlans from ‘wix-paid-plans’ ;
import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
$w.onReady( function () {
getPlan();
});
function getPlan(){
let user = wixUsers.currentUser;
let userId = user.id;
wixData.query( “PaidPlans” )
.eq( “_id” , userId)
.find()
.then( (results) => {
if (results.items.length > 0 ) {
let items = results.items;
let item = items[ 0 ];
$w( “#employerPlan” ).text = item.name;
$w( ‘#expiryUnits’ ).text = item.periodAmount;
$w( ‘#expiryTime’ ).text = item.periodUnit;
} else {
$w( “#employerPlan” ).hide();
$w( ‘#expiryUnits’ ).hide();
$w( ‘#expiryTime’ ).hide();
}
})
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
});
}