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 !
Oops it seems that this API is not available ; the link doesn't work...
Awesome ! Thank you so much !I will try that :)
@Valentin Rainui Tane 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 ;)