The Validations service plugin (formerly SPI) allows site owners and collaborators 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. Site owners and collaborators can either write their own custom validation logic, or integrate with a 3rd-party validations provider.
Wix eCommerce calls getValidationViolations()
to retrieve any violations in a site visitor's cart and checkout.
The custom validation plugin code validates the request, and returns any validation violation data in a site visitor's cart and checkout (using the structure provided by Wix eCommerce).
If there aren't any validation violations, the endpoint should return an object containing an empty array. Site visitors can see validation violations in their cart and checkout pages. For example, see the images below:
The image below shows a cart page with both a general validation violation warning and a line item validation violation warning.
The images below show a checkout page with both a general validation violation error and a line item validation violation error.
The general violation error appears at the top of the checkout page:
The error appears again above the Place Order & Pay button at the end of the page. The button is disabled until the errors are resolved.
For a step-by-step tutorial, see Validation Violations service plugin.
Future functionality includes validating products and orders.
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 config file.
getConfig()
function in the -config.js file that is added to your site during step 1.getValidationViolations()
function in the .js file that is added to your site during step 1.With the Validations service plugin you can define the validations for a cart and checkout that fit your site's needs. Possible validations include:
Term | Definition |
---|---|
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 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. |
Violations | A list of any validation violations in a site visitor's cart or checkout. |