For example: everything I have is user's ID and I need to know which paid plans this user has.
When I use getUser(userID) in backend, it returns object of type UserInfo, which doesn't have a function called getPricingPlans().
Basically what I'm doing is, I'm querying all the users from the database (Members/PrivateMembersData) and I need to know which pricing plans everyone of those users has.
Is there any way of achieving this?
Or is there any type of query that would return all users by a specific plan? For example: return all users with gold plan.
Ah I see. You can't. Two workarounds :
Solution 1: The Wix User Dashboard
Paid Plans > Purchased Plans >
Here you can filter in field Display the members that ordered Gold. You can filter on active users too if you want
Solution 2: Build your own Paid Plans back-end or use another Wi-App where you can do this.
Use For Loop to get all plan details
It doesn't exist. Vote here : https://www.wix.com/velo/requested-feature/back-end-function-for-getprincingplan
So glad I found this thread.
I'm trying to display all plans for a currently logged in user. The following code shows one plan (since I couldn't figure out how to list all plans, I listed the most recent one). I haven't tried putting a repeater or table on the page to show all. (I'd need help with that since you normally connect the data collection where the current member orders reside. CurrentMemberOrders is not listed as an available data collection to connect.)
This is what I have in on Ready:
wixUsers.currentUser.getPricingPlans() //put offset in parenthesis; to go to 2nd plan, put 1. .then((pricingPlans) => { let currentPlan = pricingPlans[pricingPlans.length - 1]; let planName = currentPlan.name; let qprice = currentPlan.price; //let benefits = currentPlan.benefits; //let sdate = currentPlan.startDate; let eDate = currentPlan.expiryDate; $w('#PlanName').value = currentPlan.name; $w('#Price').value = currentPlan.price; $w('#ExpirationDate').value = currentPlan.expiryDate.toDateString(); }); wixPaidPlans.getCurrentMemberOrders() ////put offset in parenthesis; to go to 2nd plan, put 1. //function getCurrentMemberOrders([offset: number], [limit: number]): Array<Order> .then((pricingPlans) => { let currentPlan = pricingPlans[pricingPlans.length - 1]; $w('#PlanStatus').value = currentPlan.status; })
This is what is displayed for me (I'm a member and an Admin). If I can show all plans, I'm hoping I'll see the plan I paid for as a member. And this is our second year for plans so I want members to see both years.
Below is what shows for a test user. I bought a $0 plan so I didn't have to actually pay for something in my test:
If there is a paid plan, will the amount show up? Is there a way to display $0 plans?
Thanks in advance for any guidance you can provide!
Hi
You can use the wix-paid-plans API for that
https://www.wix.com/corvid/reference/wix-paid-plans.html
But unfortunately, only to be used on page side, not on backend side. From here you can iterate on orders with a forEach for example and select on .planName.
import wixPaidPlans from 'wix-paid-plans'; async function displayOrders() { let orders = await wixPaidPlans.getCurrentMemberOrders() ... }