> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetPricePreview

# Package: pricingPlans

# Namespace: CheckoutService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/orders/get-price-preview.md

## Permission Scopes:
Read Orders: SCOPE.DC-PAIDPLANS.READ-ORDERS

## Introduction

Retrieves a plan's pricing.

The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
in the pricing model format used for orders. Learn more about [pricing models](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models).

Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To
generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.

---

## REST API

### Schema

```
 Method: getPricePreview
 Description: Retrieves a plan's pricing.  The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned in the pricing model format used for orders. Learn more about [pricing models](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models).  Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
 URL: https://www.wixapis.com/pricing-plans/v2/checkout/orders/price-preview
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  planId
 Method parameters: 
   param name: couponCode | type: couponCode | description: Coupon code to apply, from the Coupons API.  | validation: minLength 1, maxLength 20
   param name: planId | type: planId | description: GUID of plan to preview. | required: true | validation: format GUID
 Return type: GetPricePreviewResponse
  - name: prices | type: array<SpannedPrice> | description: Pricing details.  
     - name: duration | type: PriceDuration | description: Cycle duration to apply `price` for.  Use with all pricing models. Can apply the same price to multiple payment cycles.  
        - name: cycleFrom | type: integer | description: Price starts to apply with this cycle.  `1` is the first payment cycle for all pricing models.  
        - name: numberOfCycles | type: integer | description: Amount of cycles to apply price for.  For `subscription` pricing models with a finite number of cycles, the `numberOfCycles` is the same as `pricing.subscription.cycleCount`.  For `subscription` pricing models that are unlimited or until-canceled, the `numberOfCycles` is not returned.  For `singlePaymentForDuration` and `singlePaymentUnlimited` pricing models, the `numberOfCycles` is `1`.  | validation: format int32
     - name: price | type: Price | description: Order price.  
        - name: subtotal | type: string | description: Price of the order excluding tax, specified as a monetary amount. For example, `"9.99"`.  | validation: format DECIMAL_VALUE
        - name: coupon | type: Coupon | description: Coupon applied to the order, from the Coupons API.  
           - name: code | type: string | description: Code of the applied coupon.  | validation: minLength 1, maxLength 20
           - name: amount | type: string | description: Total discount of the coupon, as a monetary amount.  | validation: format DECIMAL_VALUE
           - name: id | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
        - name: discount | type: string | description: Total discount applied to the order.  | validation: format DECIMAL_VALUE
        - name: tax | type: Tax | description: Tax applied to the order.  Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).  
           - name: name | type: string | description: Name of the tax. For example, VAT.  
           - name: includedInPrice | type: boolean | description: Whether tax is included in the original price. When `false`, tax is added at checkout.  
           - name: rate | type: string | description: Tax rate percentage, as a number between 0 and 100. For example, a 7% tax rate is `"7.00"`.  | validation: format DECIMAL_VALUE
           - name: amount | type: string | description: Total tax, specified as a monetary amount. For example, `"3.99"`.  | validation: format DECIMAL_VALUE
        - name: total | type: string | description: Price after tax and discount is applied. Specified as a monetary amount, for example, `"13.98"`.  If no tax is applied, the amount is the same as `subtotal`.  | validation: format DECIMAL_VALUE
        - name: currency | type: string | description: Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.  | validation: format CURRENCY
        - name: proration | type: string | description: Price change after billing date was change and price was adjusted. Could be positive and negative values.  | validation: format DECIMAL_VALUE

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_BUSINESS_ADDRESS_STATE | Description: Business address state is missing.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_BUSINESS_ADDRESS_COUNTRY | Description: Business address country is missing.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_INVALID_SUBTOTAL | Description: Subtotal is invalid for the applied coupon.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_NOT_APPLICABLE_FOR_PLAN | Description: Coupon can't be applied to this plan.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_DOES_NOT_EXIST | Description: Coupon doesn't exist.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_HAS_EXPIRED | Description: Coupon has expired.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_IS_NOT_ACTIVE_YET | Description: Coupon isn't active yet.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_LIMIT_PER_CUSTOMER_EXCEEDED | Description: Coupon limit per customer exceeded.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_USAGE_EXCEEDED | Description: Coupon usage limit exceeded.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_IS_DISABLED | Description: Coupon is disabled and can't be applied.


```

### Examples

### GetPricePreview
```curl
~~~cURL
curl -X POST \
    'https://www.wixapis.com/pricing-plans/v2/checkout/orders/price-preview' \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    --data-raw '{
        "planId": "5779edd3-2994-4bf4-acfe-d739ad2d95ad",
        "couponCode": "FirstHalfOff"
    }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.pricingPlans.orders.getPricePreview(planId, options)
 Description: Retrieves a plan's pricing.  The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned in the pricing model format used for orders. Learn more about [pricing models](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models).  Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  planId
 Method parameters: 
   param name: planId | type: string | description: GUID of plan to preview. | required: true | validation: format GUID
   param name: options | type: GetPricePreviewOptions  none  
        - name: couponCode | type: string | description: Coupon code to apply, from the Coupons API.  | validation: minLength 1, maxLength 20
 Return type: PROMISE<GetPricePreviewResponse>
  - name: prices | type: array<SpannedPrice> | description: Pricing details.  
     - name: duration | type: PriceDuration | description: Cycle duration to apply `price` for.  Use with all pricing models. Can apply the same price to multiple payment cycles.  
        - name: cycleFrom | type: integer | description: Price starts to apply with this cycle.  `1` is the first payment cycle for all pricing models.  
        - name: numberOfCycles | type: integer | description: Amount of cycles to apply price for.  For `subscription` pricing models with a finite number of cycles, the `numberOfCycles` is the same as `pricing.subscription.cycleCount`.  For `subscription` pricing models that are unlimited or until-canceled, the `numberOfCycles` is not returned.  For `singlePaymentForDuration` and `singlePaymentUnlimited` pricing models, the `numberOfCycles` is `1`.  | validation: format int32
     - name: price | type: Price | description: Order price.  
        - name: subtotal | type: string | description: Price of the order excluding tax, specified as a monetary amount. For example, `"9.99"`.  | validation: format DECIMAL_VALUE
        - name: coupon | type: Coupon | description: Coupon applied to the order, from the Coupons API.  
           - name: code | type: string | description: Code of the applied coupon.  | validation: minLength 1, maxLength 20
           - name: amount | type: string | description: Total discount of the coupon, as a monetary amount.  | validation: format DECIMAL_VALUE
           - name: _id | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
        - name: discount | type: string | description: Total discount applied to the order.  | validation: format DECIMAL_VALUE
        - name: tax | type: Tax | description: Tax applied to the order.  Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).  
           - name: name | type: string | description: Name of the tax. For example, VAT.  
           - name: includedInPrice | type: boolean | description: Whether tax is included in the original price. When `false`, tax is added at checkout.  
           - name: rate | type: string | description: Tax rate percentage, as a number between 0 and 100. For example, a 7% tax rate is `"7.00"`.  | validation: format DECIMAL_VALUE
           - name: amount | type: string | description: Total tax, specified as a monetary amount. For example, `"3.99"`.  | validation: format DECIMAL_VALUE
        - name: total | type: string | description: Price after tax and discount is applied. Specified as a monetary amount, for example, `"13.98"`.  If no tax is applied, the amount is the same as `subtotal`.  | validation: format DECIMAL_VALUE
        - name: currency | type: string | description: Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.  | validation: format CURRENCY
        - name: proration | type: string | description: Price change after billing date was change and price was adjusted. Could be positive and negative values.  | validation: format DECIMAL_VALUE

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_BUSINESS_ADDRESS_STATE | Description: Business address state is missing.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_BUSINESS_ADDRESS_COUNTRY | Description: Business address country is missing.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_INVALID_SUBTOTAL | Description: Subtotal is invalid for the applied coupon.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_NOT_APPLICABLE_FOR_PLAN | Description: Coupon can't be applied to this plan.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_DOES_NOT_EXIST | Description: Coupon doesn't exist.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_HAS_EXPIRED | Description: Coupon has expired.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_IS_NOT_ACTIVE_YET | Description: Coupon isn't active yet.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_LIMIT_PER_CUSTOMER_EXCEEDED | Description: Coupon limit per customer exceeded.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_USAGE_EXCEEDED | Description: Coupon usage limit exceeded.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ERROR_COUPON_IS_DISABLED | Description: Coupon is disabled and can't be applied.


```

### Examples

### Get a price preview for an order with options
```javascript
import { orders } from '@wix/pricing-plans';

/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'
 *
 * Sample options value:
 * {
 *   couponCode: 'SUMMERSALE'
 * }
 */ 

export async function myGetPricePreviewFunction(planId, options) {
  try {
    const pricePreview = await orders.getPricePreview(planId, options);

    return pricePreview;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "prices": [
 *     {
 *       "duration": {
 *         "cycleFrom": 1,
 *         "numberOfCycles": 1
 *       },
 *       "price": {
 *         "coupon": {
 *           "code": "SUMMERSALE",
 *           "amount": "90.00",
 *           "_id": "271d5fe4-2105-47b8-81c1-b24201d1be68"
 *         },
 *         "discount": "90.00",
 *         "currency": "USD",
 *         "subtotal": "125.00",
 *         "tax": {
 *           "amount": "2.28",
 *           "includedInPrice": false,
 *           "name": "Tax",
 *           "rate": "6.5",
 *         },
 *         "total": "37.28"
 *       }
 *     },
 *     {
 *       "duration": {
 *         "cycleFrom": 2
 *       },
 *       "price": {
 *         "coupon": {
 *           "code": "SUMMERSALE",
 *           "amount": "90.00",
 *           "_id": "271d5fe4-2105-47b8-81c1-b24201d1be68"
 *         },
 *         "discount": "90.00",
 *         "currency": "USD",
 *         "subtotal": "100.00",
 *         "tax": {
 *           "amount": "0.65",
 *           "includedInPrice": false,
 *           "name": "Tax",
 *           "rate": "6.5"
 *         },
 *         "total": "10.65",
 *       }
 *     }
 *   ]
 * }
 */
```

### Get a price preview for an order
```javascript
import { orders } from '@wix/pricing-plans';

/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */

export async function myGetPricePreviewFunction(planId) {
  try {
    const pricePreview = await orders.getPricePreview(planId);

    return pricePreview;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}
/* Promise resolves to:
 * {
 *   "prices": [
 *     {
 *       "duration": {
 *         "cycleFrom": 1,
 *         "numberOfCycles": 2
 *       },
 *       "price": {
 *         "currency": "USD",
 *         "discount": "0"
 *         "proration": "0",
 *         "subtotal": "500.00",
 *         "tax": {
 *           "name": "Tax",
 *           "includedInPrice": false,
 *           "rate": "6.5",
 *           "amount": "32.50"
 *         },
 *         "total": "532.50"
 *       }
 *     }
 *   ]
 * }
 */ 
```

### getPricePreview (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { orders } from '@wix/pricing-plans';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { orders },
  // Include the auth strategy and host as relevant
});


async function getPricePreview(planId,options) {
  const response = await myWixClient.orders.getPricePreview(planId,options);
};
```

---