Issues showing a button based on member paid membership

Hi!
I’m currently trying to add some code to my site to only display a specific button to a specific paid membership. I’ve been trying to guide myself using documentation from the corvid reference about the getCurrentMemberOrders() function.

So far I tried the following code:

//enable Button if paid plan is the correct one
$w('#testButton').hide();
wixPaidPlans.getCurrentMemberOrders() .then ( (planName) => { if (planName.some(p => p.name === "INFINITY")){$w('#testButton').show();}} ) ;

But that’s not working at all. I’ve found questions and articles about showing buttons based on member roles, but I haven’t found anything concrete on showing buttons based on paid memberships.

Does anyone know what I’m doing wrong in the code above? Could someone please shed some light on this🤔.

1 Like

Looking to do the same thing and can’t find a solution anywhere! :frowning:

So far I haven’t been able to solve this, how about you?

So far I haven’t been able to deploy my service because of this particular roadblock :frowning:

I’ve been trying to research more about this, but there’s simply not much to go from.

Hey! I got it.

I had it all wrong. I sat down and rewrote the whole code after rethinking the logic of what I wanted to happen.

I tried something like this:

user.getPricingPlans()
.then((pricingPlans) => {
 let firstPlan = pricingPlans[0];
 let planName = firstPlan.name; 
 console.log(planName); //just for debugging
 if (planName === "INFINITY") {
 console.log("You are VIP :)"); //just for debugging
 $w("#testPlanButton").show();
} else {
console.log("lol not vip") //just for debugging
}
});

After deploying the above code, the test button I created worked as it’s supposed. Now I can get going and implement a version of that code in my site’s features! :slight_smile:

Good luck to everyone that reads this post!

Be sure to include:

import wixUsers from 'wix-users';