Hi,
I need buttons to show/hide on 4 different membership plan status:
-
ACTIVE
-
CANCELED
-
SUSPENDED
-
UNDEFINED
Unfortunately only status CANCELED works.
Console error says: TypeError: Cannot read property ‘planName’ of undefined
How can I refer to UNDEFINED? Why are ACTIVE/SUSPENDED not working?
import wixUsers from ‘wix-users’ ;
import wixPaidPlans from ‘wix-paid-plans’ ;
$w.onReady( function () {
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
wixPaidPlans.getCurrentMemberOrders()
.then ( orders => {
let plan = orders[ 0 ];
let paket = plan.planName;
let stat = plan.status;
let aktivseit = plan.validFrom;
let aktivbis = plan.validUntil;
$w( “#statusv” ).text = stat;
$w( “#paketv” ).text = paket;
$w( “#aktivv” ).text = aktivseit.toString();
$w( “#expiryv” ).text = aktivbis.toString();
if (plan.status=== “ACTIVE” ) {
$w( “#resume” ).hide();
$w( “#pause” ).show();
}
else if (plan.status=== “CANCELED” ) {
$w( “#resume” ).hide();
$w( “#pause” ).hide();
}
else if (plan.status=== “SUSPENDED” ) {
$w( “#resume” ).show();
$w( “#pause” ).hide();
}
else {
$w( “#box1” ).hide();
}
})
. catch ( (err) => {
console.log(err); })
})