> 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 ## Resource: Introduction ## Article: Introduction ## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/introduction.md ## Article Content: # About the Wix eCommerce Validations Service Plugin
__Important:__ When developing websites or building apps with Blocks, use [Velo service plugins](https://dev.wix.com/docs/velo/events-service-plugins/about-events-service-plugins-and-the-sdk.md).
As a validations provider, you can integrate with Wix to allow Wix users to validate a site visitor's cart and checkout. For example, you can validate a specific line item’s quantity if the quantity per order is limited. Wix users can either write their own custom validation logic, or integrate with a 3rd-party validations provider. The integration is done via an app in the Wix App Market and by implementing the Validations [service plugin](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md). After the app is installed on a site, Wix triggers a call to your service whenever the site needs to validate a cart or checkout. If there aren't any validation violations, the method should return an object containing an empty array. Using the service plugin, you can design your app to validate a cart and checkout for your merchant's customers, including: + Minimum cart value. + Age of a customer before they proceed to checkout. + Line item quantity limit. + Valid coupon code. + Specific items to ship only to specific regions. + Restrict purchases to site members only. + Close the checkout on certain days. ## Before you begin By default, the Validations service plugin only validates a site visitor's checkout. If you want to also validate a site visitor's cart, set the `validateInCart` parameter to `true` in the service plugin's configuration. ## Use Cases Using the service plugin, you can design your app to validate a cart and checkout for your merchant's customers, including: + Minimum cart value. + Age of a customer before they proceed to checkout. + [Line item quantity limit](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/sample-flow.md#wix-ecommerce_validations-integration-spi_sample-flow_validate-a-line-item's-quantity). + [Valid coupon code](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/sample-flow.md#wix-ecommerce_validations-integration-spi_sample-flow_validate-a-coupon-code-for-a-wix-checkout). + Specific items to ship only to specific regions. + Restrict purchases to site members only. + Close the checkout on certain days. ::::tabs :::REST_TAB ## Get started To enable Wix to communicate with your app: 1. Go to [Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/about-extensions.md) in your app's dashboard. 1. Click **Create Extension** in the top right. 1. Filter by **eCommerce** in the left menu, then find **Ecom Validations** and click **Create**. 1. Provide the following configuration: | Name | Type | Description | | --- | --- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `deploymentUri`|string| Required. Base URI where the endpoints are called. Wix appends the endpoint path to the base URI. For example, to call the Get Validation Violations endpoint at `https://my-validations.com/v1/get-violations`, the base URI you provide here is `https://my-validations.com`. | | `componentName`|string| A unique name for this component. This is an internal name that will only appear in the app dashboard. | | `validateInCart`|boolean| Whether to validate the cart page in addition to the checkout page. Default: `false` | ::: :::SDK_TAB ## Get started Follow these steps to begin implementing your service plugin. ### Step 1 | Choose a framework You can implement this service plugin with the following [frameworks](https://dev.wix.com/docs/build-apps/get-started/overview/wix-s-development-frameworks.md): + **Wix CLI:** Learn how to [implement a service plugin with the CLI and the SDK](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md). + **Self-hosted:** Learn how to [implement a self-hosted service plugin with the SDK and the Wix Dev Center](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md). ### Step 2 | Configure your service plugin To configure and customize your plugin, you need to provide important information in the service plugin configuration file. You can [configure your plugin in the Wix Dev Center](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-1--add-a-service-plugin-extension-to-your-app). For details, see [Validations Extension Configuration](https://dev.wix.com/docs/rest/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/extension-config.md). ### Step 3 | Define handler functions Use [`validations.provideHandlers()`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-4--define-handler-functions) to define the following handler functions that implement your custom business logic. Make sure you define all required functions. | Function | Required | |-----------------------------|----------------| | [`getValidationViolations()`](https://dev.wix.com/docs/rest/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/get-validation-violations.md) | Yes | ## Code examples Below is an example for implementing the Validations service plugin in your code. ### CLI: Basic code structure This is the basic code structure for implementing the Validations service plugin with the Wix CLI: ```js import { validations } from '@wix/ecom/service-plugins' validations.provideHandlers({ getValidationViolations: async (payload) => { const {request, metadata} = payload; // Add your logic here } }); ``` ### Self-hosted: Basic code structure This is the basic code structure for implementing a self-hosted Validations service plugin: ```js import { createClient } from '@wix/sdk'; import { validations } from '@wix/ecom/service-plugins' const wixClient = createClient({ auth: { appId: , publicKey: }, modules: { validations } }); wixClient.validations.provideHandlers({ getValidationViolations: async (payload) => { const { request, metadata } = payload; // Add your logic here } }); // Implement a router to process all requests express.post('/plugins-and-webhooks/*', (req, res) => { wixClient.process(req); }); ``` ::: :::: ## Terminology - **Merchant:** Business that offers products on their Wix site to customers. - **Severity:** How severe the violation is. The violations are shown on the cart and checkout pages. A warning is displayed as yellow, and allows a site visitor to proceed with caution. An error is displayed as red, and doesn't allow a site visitor to proceed with the eCommerce flow. - **Subscription option:** A store owner can create [subscriptions](https://support.wix.com/en/article/wix-stores-selling-product-subscriptions) to sell their products on a recurring basis. A line item can be a subscription. - **Target:** Target location on a checkout or cart page where the violation will be displayed. The target violation can either be in a particular `lineItem`, or in an `other` area of the cart or checkout page. - **Validation service provider:** A 3rd-party app that implements custom logic to validate the site's cart or checkout. - **Violations:** A list of any validation violations in a site visitor's cart or checkout. ## See also + [About Service Plugin Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md) + [Add a Service Plugin Extension With the CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md) + [Add a Self-hosted Service Plugin With the SDK](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md) + [Add Self-hosted Service Plugin Extensions with REST](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-rest.md)