Question Body
Hi everyone,
I’m having difficulty retrieving the active Pricing Plan name for the currently logged-in user in my Velo backend code. My goal is to use this plan name to enforce usage limits (quotas) on a button click in the frontend.
The Goal
I need a reliable backend function that returns the string value of the user’s active plan (e.g., 'Pro', 'Basic', or 'Default') so I can determine the template creation limit on the frontend.
My Backend Code Attempts (plans.jsw)
I’ve attempted several methods using wix-pricing-plans-backend, but they all fail to correctly identify my active plan and consistently return 'Default' in the logs:
-
Attempt 1: Using
getPlanOrderswith a query (which works for some users):JavaScript
import wixPricingPlansBackend from "wix-pricing-plans-backend"; import wixUsers from 'wix-users-backend'; export async function getActivePlanName() { // ... (code to check userId) try { const ordersResult = await wixPricingPlansBackend.getPlanOrders({ query: wixPricingPlansBackend.queryPlanOrders() .eq("receiverId", userId) .hasSome("status", ["Active", "Pending"]) // Statuses may be the issue .limit(1) }); // ... (check ordersResult and return planName) } catch (error) { // ... } } -
Attempt 2: Using
isPlanMember(which shows red in my Velo editor, indicating a Linter issue):JavaScript
// ... const isPro = await wixPricingPlansBackend.isPlanMember('Pro'); if (isPro) return 'Pro'; // ...
The Result
The console consistently shows the following output, indicating the backend is failing to retrieve the actual plan name:
console.logfrom Backend: “Found active plan: Default”
console.logfrom Frontend: “Quota Check: FULL. Current: 0, Limit: 0. Opening NoTemplate.”
My Questions
-
What is the most stable and currently supported Velo API function to reliably get the active plan name of the current user, avoiding Linter errors like the ones I’m seeing with
queryPlanOrdersandisPlanMember? -
Are there specific Wix Pricing Plan statuses (like
'TRIAL'or'FREE') that I must include in my query, or is the issue more likely related to file permissions on the backend JSW file? (Permissions are currently set to ‘Site Member’).
Any guidance on the correct API usage or troubleshooting data/permissions would be greatly appreciated!
Thank you!
Eliran