Search.../

Introduction

The Validations SPI custom extension 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 extension 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.

Cart page warning

The image below shows a checkout page with both a general validation violation error and a line item validation violation error.

Checkout page errors

For a step-by-step tutorial, see Validation Violations SPI custom extension.

Future functionality includes validating products and orders.

Before you begin

By default, the Validations SPI 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 custom extension's config file.

To add a custom extension

  1. Add the extension to your site.
  2. Update the getConfig() function in the -config.js file that is added to your site during step 1.
  3. Update the getValidationViolations() function in the .js file that is added to your site during step 1.

Use Cases

With the Validations SPI you can define the validations for a cart and checkout that fit your site's needs. Possible validations include:

  • Minimum subtotal amount to qualify for free shipping.
  • Age of a customer before they proceed to checkout.
  • Specific items to ship only to specific regions.
  • Restrict purchases to site members only.
  • Close checkout on certain days.

Terminology

TermDefinition
SeverityHow 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 OptionA store owner can create subscriptions to sell their products on a recurring basis. A line item can be a subscription.
TargetTarget 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.
ViolationsA list of any validation violations in a site visitor's cart or checkout.

Was this helpful?