How to access list of all users with their paid plan

Question:
I am using wix-data api on the backend of my website,

the goal is to send an email monthly to the users who has purchased a plan.

I successfully get all users using this code:

       const result = await wixData.query("Members/FullData").find({ suppressAuth: true 
       });
        const items = result.items.map(elem => {
            return {
                email: elem.loginEmail,
                firstName: elem.firstName,
                lastName: elem.lastName,
                company: elem.customfields_contact_company,
                position: elem.customfields_contact_position,
                website: elem.custom_webseite,
                linkedin: elem.custom_linkedin,
                instagram: elem.custom_instagram,
            }
        });

** The Problem **
I cannot get users’ plan to make sure I am sending an email to the user who has the plan.

I have checked out this link: Get paid plans of a user ID
But it did not help. I know that I can get the logged in user plan, but I am running a scheduled job to do this, and I need list of all users.

What I want is quite straightforward, accessing all users’ paid plan on backend code!

Product:
Wix Editor

I think this is what you might need - List Orders | VELO

You should be able to list all the orders for a specific plan (along with additional info about the order, such as payment status, startDate etc.

You also get the buyer info, including contactId and memberId which can be used to get more info about the member.


Worth noting that it’ll resolve to a list of up to 50 pricing plan orders, so you may need to take this into consideration and loop through to collect all orders.

Hope this helps :slight_smile: