Retrieve pricing plan for every members

Hi, i’d like to set up a Cron job every night to update my databases depending on whether or not my members are up to date with their pricing plans.
Here is the chunk of code that I created already, however I don’t see any possible way to retrieve if the specific member has a plan or not :

import wixData from 'wix-data';
import { members } from 'wix-members-backend';

export function checkPlansForEveryUser() {
    wixData.query("Members/PrivateMembersData")
        .limit(1000)
        .find()
        .then((results) => {
            let allMembers = results.items

            for (let i = 0; i < allMembers.length; i++) {
                members.getMember(allMembers[i]._id, { fieldsets: ['FULL'] })
                    .then((member) => {
                        console.log(member) // provides all member's data except pricing plan
                    })

            }
        });
}

Thank you !

1 Like

@valentinloppe You are in luck.

Wix’s just published new APIs for that:

You should be able to retrieve subscription for a given member via
https://www.wix.com/velo/reference/wix-pricing-plans-backend/orders/listorders

In this case, you don’t need to retrieve the member as you can directly use their Ids.

Have fun :wink:

Awesome ! Thank you so much !I will try that :slight_smile:

Oops it seems that this API is not available ; the link doesn’t work…

Apparently they got some rework to do but it will be release eventually

IT DOESN’T EXIST !!!