Hide/show elements based on a user paid plans

Hi

I am trying to hide and show buttons on a page based on the name of a users paid plan.

So far I have this code to get the plan name. Can anyone help further?

Many thanks
Sian

import wixUsers from ‘wix-users’ ;
let user = wixUsers . currentUser ;

$w . onReady (()=> {
user . getPricingPlans (). then (( plans ) => {
if ( plans . length > 0 ) {
let $w ( “textPlanTitle” ). plans . Name
$w ( “#text35” ). hide ();
$w ( ‘#buynowButton’ ). hide ();
// The member has paid plan purchased
// Handle the case here by showing and
// hiding elements
} else {
// handle the case where user doesn’t have
// pricing plan
}
})
})

Hello! A few things…

First, I would update wixUsers to use wix members. Wix users will still work, but it has been deprecated so it is not advised for the future.

Secondly, to get the current members orders you can take a look at this API which should help you finish your conditions
https://www.wix.com/velo/reference/wix-pricing-plans/orders/listcurrentmemberorders

1 Like

I’m building a marketplace that displays profiles of members. Each member needs to first purchase a paid plan in order to create their profile. On the Marketplace page, I have a repeater that displays all the member profiles.

MY QUESTION:
Is it possible to check the status of a member’s plan and hide member profiles if status is PAUSED or CANCELED — basically if the plan is not ACTIVE?

Yes, everything is possible! If Wix has provided APIs for your wished element/scenario/functionality → then there also is a way to generate what you want/need.

Take a look onto the following example…

If your wished functionality will work or not, depends on…

Check the API and get your conclusion.

API given for → pause a plan? → I think yes, because i have seen already!
API for cancel an plan-order? → you see the example.
API for make a plan-order-list? → you see the example.
API for marking orders as paid → was also in example (just not mentioned), but possible.

…and so on…and so on…

This works:
import wixData from ‘wix-data’;

$w.onReady(() => {

wixData.query("CreativePartnerProfile")
    .include("referenceSubscriptionStatus")
    .find()
    .then(results => {
        let profileSubscriptionStatus = new Map();
        results.items.forEach(profile => {
            profileSubscriptionStatus.set(profile._id, profile.referenceSubscriptionStatus.status);
        });

        // Setup repeater to display profiles based on subscription status
        $w("#partnerRepeater").onItemReady(($item, itemData, index) => {
            if (profileSubscriptionStatus.get(itemData._id) === "ACTIVE") {
                $item("#partnerContainer").show();
                setupItemInteractivity($item, itemData);
            } else {
                $item("#partnerContainer").hide();
            }
        });
    })
    .catch((error) => {
        console.error("Error loading profiles:", error);
    });

});

1 Like

That post somehow connected to you ?

Maybe you want to provide your solution.