> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: queryPublicPlans() # Method package: wixPricingPlansBackend # Method menu location: wixPricingPlansBackend --> queryPublicPlans # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/query-public-plans.md # Method Description: Creates a query to retrieve a list of public pricing plans. The `queryPublicPlans()` function builds a query to retrieve a list of up to 1,000 public plans and returns a [`PublicPlansQueryBuilder`](wix-pricing-plans-backend/public-plans-query-builder) object. The returned object contains the query definition which is typically used to run the query using the [`find()`](wix-pricing-plans-backend/public-plans-query-builder/find) function. You can refine the query by chaining [`PublicPlansQueryBuilder`](wix-pricing-plans-backend/Public-Plans-Query-Builder) functions onto the query. `PublicPlansQueryBuilder` functions enable you to sort, filter, and control the results that `queryPublicPlans()` returns. `queryPublicPlans()` runs with the following [`PublicPlansQueryBuilder`](wix-pricing-plans-backend/Public-Plans-Query-Builder) defaults that you can override: + [`skip`](wix-pricing-plans-backend/Public-Plans-Query-Builder/skip): `0` + [`limit`](wix-pricing-plans-backend/Public-Plans-Query-Builder/limit): `50` The functions that are chained to `queryPublicPlans()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the `_id` property in ascending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by `_id` in ascending order, per created date value. The following [`PublicPlansQueryBuilder`](wix-pricing-plans-backend/Public-Plans-Query-Builder) functions are supported for `queryPublicPlans()`. |Property|Filters|Examples| |--|--|--| |`_id`|[`eq()`](wix-pricing-plans-backend/public-plans-query-builder/eq), [`ne()`](wix-pricing-plans-backend/public-plans-query-builder/ne), [`hasSome()`](wix-pricing-plans-backend/public-plans-query-builder/hasSome)|`hasSome("_id", ["46ce4cd4-46ff-13a1-43ac-02fd4f0f3209", "94ce4cd4-46cc-20c3-4c7a-03fd4f0f3306"])`| |`primary` |[`eq()`](wix-pricing-plans-backend/public-plans-query-builder/eq), [`ne()`](wix-pricing-plans-backend/public-plans-query-builder/ne), [`ascending()`](wix-pricing-plans-backend/public-plans-query-builder/ascending), [`descending()`](wix-pricing-plans-backend/public-plans-query-builder/descending)|`eq("primary",true)`| |`slug`|[`eq()`](wix-pricing-plans-backend/public-plans-query-builder/eq), [`ne()`](wix-pricing-plans-backend/public-plans-query-builder/ne), [`startsWith()`](wix-pricing-plans-backend/public-plans-query-builder/startsWith), [`endsWith()`](wix-pricing-plans-backend/public-plans-query-builder/endsWith), [`contains()`](wix-pricing-plans-backend/public-plans-query-builder/contains), [`ascending()`](wix-pricing-plans-backend/public-plans-query-builder/ascending), [`descending()`](wix-pricing-plans-backend/public-plans-query-builder/descending)|`eq("gold")`| |`_createdDate`|[`eq()`](wix-pricing-plans-backend/public-plans-query-builder/eq), [`ne()`](wix-pricing-plans-backend/public-plans-query-builder/ne), [`gt()`](wix-pricing-plans-backend/public-plans-query-builder/gt), [`ge()`](wix-pricing-plans-backend/public-plans-query-builder/ge), [`lt()`](wix-pricing-plans-backend/public-plans-query-builder/lt), [`le()`](wix-pricing-plans-backend/public-plans-query-builder/le), [`between()`](wix-pricing-plans-backend/public-plans-query-builder/between), [`ascending()`](wix-pricing-plans-backend/public-plans-query-builder/ascending), [`descending()`](wix-pricing-plans-backend/public-plans-query-builder/descending)|`lt("_createdDate", "2020-04-27T10:00:00.000Z")`| |`_updatedDate`|[`eq()`](wix-pricing-plans-backend/public-plans-query-builder/eq), [`ne()`](wix-pricing-plans-backend/public-plans-query-builder/ne), [`gt()`](wix-pricing-plans-backend/public-plans-query-builder/gt), [`ge()`](wix-pricing-plans-backend/public-plans-query-builder/ge), [`lt()`](wix-pricing-plans-backend/public-plans-query-builder/lt), [`le()`](wix-pricing-plans-backend/public-plans-query-builder/le), [`between()`](wix-pricing-plans-backend/public-plans-query-builder/between), [`ascending()`](wix-pricing-plans-backend/public-plans-query-builder/ascending), [`descending()`](wix-pricing-plans-backend/public-plans-query-builder/descending)|`ge("_updatedDate", "2020-04-27T10:00:00.000Z")`| >**Notes:** > + When using the `queryPublicPlans()` function immediately following a change to your plans, > the data retrieved may not contain your most recent changes. See [Wix-data and Eventual Consistency](wix-data/introduction#wix-data-and-eventual-consistency) > for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay > querying following any changes to your plan data. > The [`find()`](wix-pricing-plans-backend/public-plans-query-builder/find) function executes the query based on this query object, and returns the actual result, [`PublicPlansQueryResult`](wix-pricing-plans-backend/PublicPlansQueryResult). > + You do not need "Manage Pricing Plans" permissions to query public plans. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Build and execute a query to find all public plans ```javascript import { Permissions, webMethod } from 'wix-web-module'; import wixPricingPlansBackend from 'wix-pricing-plans-backend'; export const myQueryPublicPlansFunction = webMethod(Permissions.Anyone, () => { return wixPricingPlansBackend.queryPublicPlans() .find() .then((result) => { console.log(result); }) .catch((error) => { console.error(error); }); }); // Query results /* * { * "items": [ * { * "_id": "3fb6a3c8-988b-7896-04bd-6c69ae0b18eb", * "name": "Gold", * "description": "For expert gamers", * "perks": [ * "Great value for your money", * "Multi-user" * ], * "pricing": { * "singlePaymentUnlimited": true, * "price": { * "value": "100", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2020-12-21T15:13:06.202Z", * "_updatedDate": "2020-12-30T17:10:01.202Z", * "slug": "gold", * "maxPurchasesPerBuyer": 1, * "allowFutureStartDate": false, * "buyerCanCancel": true * }, * { * "_id": "9e76b9dc-a3a6-3e25-ada5-a1ace10ccbeb", * "name": "Gold Plus", * "description": "Updated description for the original Gold plan", * "perks": [ * "Multiplayer", * "Multiple devices", * "No ads", * "Unlimited access" * ], * "pricing": { * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "cycleCount": 3 * }, * "price": { * "value": "23", * "currency": "USD" * }, * "freeTrialDays": 7 * }, * "primary": false, * "_createdDate": "2020-12-21T15:14:08.018Z", * "_updatedDate": "2020-12-30T15:13:07.018Z", * "slug": "gold-plus", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "" * }, * { * "_id": "22f234bf-a3a6-7c32-abc1-88101ffcb2ef", * "name": "Silver", * "description": "For advanced gamers", * "perks": [ * "Great avatar selection and background tunes", * "All perks of Bronze membership" * ], * "pricing": { * "singlePaymentForDuration": { * "count": 3, * "unit": "MONTH" * }, * "price": { * "value": "24", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2020-12-21T15:13:10.327Z", * "_updatedDate": "2020-12-30T19:02:13.327Z", * "slug": "silver", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "" * } * ] * } */ ``` ## Build and execute a query to find public plans created before a certain date ```javascript import { Permissions, webMethod } from 'wix-web-module'; import wixPricingPlansBackend from 'wix-pricing-plans-backend'; export const myQueryPublicPlansFunction = webMethod(Permissions.Anyone, () => { return wixPricingPlansBackend.queryPublicPlans() .lt("_createdDate", "2021-01-15T10:00:00.000Z") .find() .then((result) => { console.log(result); }) .catch((error) => { console.error(error); }); }); // Query results /* * { * "items": [ * { * "_id": "3fb6a3c8-988b-7896-04bd-6c69ae0b18eb", * "name": "Gold", * "description": "For expert gamers", * "perks": [ * "Great value for your money", * "Multi-user" * ], * "pricing": { * "singlePaymentUnlimited": true, * "price": { * "value": "100", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2020-12-21T15:13:06.202Z", * "_updatedDate": "2020-12-30T10:14:03.202Z", * "slug": "gold", * "maxPurchasesPerBuyer": 1, * "allowFutureStartDate": false, * "buyerCanCancel": true * }, * { * "_id": "9e76b9dc-a3a6-3e25-ada5-a1ace10ccbeb", * "name": "Gold Plus", * "description": "Updated description for the original Gold plan", * "perks": [ * "Multiplayer", * "Multiple devices", * "No ads", * "Unlimited access" * ], * "pricing": { * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "cycleCount": 3 * }, * "price": { * "value": "23", * "currency": "USD" * }, * "freeTrialDays": 7 * }, * "primary": false, * "_createdDate": "2020-12-21T15:13:07.018Z", * "_updatedDate": "2020-12-30T15:11:11.028Z", * "slug": "gold-plus", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "" * }, * { * "_id": "22f234bf-a3a6-7c32-abc1-88101ffcb2ef", * "name": "Silver", * "description": "For advanced gamers", * "perks": [ * "Great avatar selection and background tunes", * "All perks of Bronze membership" * ], * "pricing": { * "singlePaymentForDuration": { * "count": 3, * "unit": "MONTH" * }, * "price": { * "value": "24", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2020-12-21T15:13:10.327Z", * "_updatedDate": "2020-12-30T15:11:11.117Z", * "slug": "silver", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "" * } * ] * } * */ ``` ---