items


itemsArray<Item>Read-only

Returns the items that match the query.

The current page of items retrieved by the query.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no items match the query, the items array is empty.

Perform a query and get the public pricing plan items from the result
JavaScript
import wixPricingPlansBackend from "wix-pricing-plans-backend"; // ... wixPricingPlansBackend .queryPublicPlans() .find() .then((results) => { if (results.items.length > 0) { const items = results.items; // see below } else { // handle case where no matching items found } }) .catch((error) => { const queryError = error; }); /* items: * [ * { * "plan": { * "_id": "5269ddde-a3a6-7c32-abc1-fe8af8331097", * "name": "Basic", * "description": "This plan provides the basics.", * "pricing": { * "singlePaymentUnlimited": true, * "price": { * "value": "50", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2021-01-01T15\:33\:34.860Z", * "_updatedDate": "2021-01-14T10\:30\:30.870Z", * "slug": "basic", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "", * "perks": [ * "Essentials only", * "For beginners" * ] * } * }, * { * "plan": { * "_id": "31c26520-a3a6-7c32-abc1-d4b11e509a92", * "name": "Intermediate", * "description": "This plan provides intermediate capabilities", * "pricing": { * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "cycleCount": 2 * }, * "price": { * "value": "25", * "currency": "USD" * }, * "freeTrialDays": 3 * }, * "primary": false, * "_createdDate": "2020-02-14T15\:33\:34.977Z", * "_updatedDate": "2021-01-14T10\:30\:30.970Z", * "slug": "intermediate", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "", * "perks": [ * "Cool templates you can reuse", * "Includes the Basic plan" * ] * } * }, * { * "plan": { * "_id": "6e01c2ae-b3b6-7a33-abc1-b7daf0fd125c", * "name": "Advanced", * "description": "This plan provides advanced capabilities", * "pricing": { * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "YEAR" * }, * "cycleCount": 0 * }, * "price": { * "value": "100", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2020-12-14T15\:33\:35.677Z", * "_updatedDate": "2021-01-14T11\:33\:11.677Z", * "slug": "advanced", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "perks": [ * "Extra utilities, plug-ins", * "Includes the Intermediate Plan" * ] * } * }, * { * "plan": { * "_id": "a7fff6ae-b3b6-7a33-abc1-2b9f8b39e6c5", * "name": "Advanced VIP", * "description": "This plan provides a lot of extras that are really cool in addition to the regular Advanced plan", * "pricing": { * "singlePaymentUnlimited": true, * "price": { * "value": "125", * "currency": "USD" * } * }, * "primary": false, * "_createdDate": "2021-01-14T15\:33\:35.782Z", * "_updatedDate": "2021-01-14T15\:33\:35.782Z", * "slug": "advanced-vip", * "allowFutureStartDate": false, * "buyerCanCancel": true, * "termsAndConditions": "", * "perks": [ * "Free beer and champagne sent to your home when you purchase the plan", * "Discount on our merchandise", * "Includes the Advanced plan" * ] * } * } * ] */
Did this help?

length


lengthnumberRead-only

Returns the number of items in the current results page.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

JavaScript
const resultLength = results.length; // 20
Did this help?

pageSize


pageSizenumberRead-only

Returns the query page size.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

JavaScript
const resultPageSize = results.pageSize; // 50
Did this help?

query


Returns the query used to get the current results.

JavaScript
const resultQuery = results.query;
Did this help?

totalCount


totalCountnumberRead-only

Returns the total number of items that match the query.

The totalCount returns the total number of items that match the query, not just the number of items in the current page.

JavaScript
const resultCount = results.totalCount; // 150
Did this help?

totalPages


totalPagesnumberRead-only

Returns the total number of pages the query produced.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

JavaScript
const resultPages = results.totalPages; // 3
Did this help?

hasNext( )


Indicates if the query has more results.

Method Declaration
Copy
function hasNext(): boolean;
Request
This method does not take any parameters
Returns
Return Type:boolean
JavaScript
const hasNext = results.hasNext(); // true
Did this help?

hasPrev( )


Indicates the query has previous results.

Method Declaration
Copy
function hasPrev(): boolean;
Request
This method does not take any parameters
Returns
Return Type:boolean
Get the previous page of a query result
JavaScript
const hasPrev = results.hasPrev(); // false
Did this help?

next( )


Retrieves the next page of query results.

The next() function retrieves the next page of query results.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

If items are added or removed between calls to next() the values returned by PublicPlansQueryResult may change.

Method Declaration
Copy
function next(): Promise<PublicPlansQueryResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<PublicPlansQueryResult>
JavaScript
oldResults .next() .then((results) => { const newResults = results; const items = newResults.items; const firstItem = items[0]; const totalCount = newResults.totalCount; const pageSize = newResults.pageSize; const currentPage = newResults.currentPage; const totalPages = newResults.totalPages; const hasNext = newResults.hasNext(); const hasPrev = newResults.hasPrev(); const length = newResults.length; const query = newResults.query; }) .catch((error) => { const queryError = error; });
Did this help?

prev( )


Retrieves the previous page of query results.

The prev() function retrieves the previous page of query results.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

If items are added or removed between calls to prev() the values returned may change.

Method Declaration
Copy
function prev(): Promise<PublicPlansQueryResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<PublicPlansQueryResult>
Get the previous page of a query result
JavaScript
oldResults .prev() .then((results) => { const newResults = results; const items = newResults.items; const firstItem = items[0]; const totalCount = newResults.totalCount; const pageSize = newResults.pageSize; const currentPage = newResults.currentPage; const totalPages = newResults.totalPages; const hasNext = newResults.hasNext(); const hasPrev = newResults.hasPrev(); const length = newResults.length; const query = newResults.query; }) .catch((error) => { const queryError = error; });
Did this help?