Validations Service Plugin Reference
Overview
The Validations SPI lets you add custom validation rules to the checkout process. You can validate cart contents, order totals, quantities, or any business logic requirement. Implement the getValidationViolations handler — it evaluates the order and returns any violations.
Request and Response Schema
Before implementing, call ReadFullDocsMethodSchema on the docs URL to get the full request/response types.
Example: Minimum Quantity Validation
This example validates that the order meets a minimum item quantity requirement.
import { validations } from "@wix/ecom/service-plugins";
validations.provideHandlers({
getValidationViolations: async (payload) => {
const { request, metadata } = payload;
// Use the `request` and `metadata` received from Wix and
// apply custom logic.
return {
// Return your response exactly as documented to integrate with Wix.
// Return value example:
violations: [
{
description: "You must purchase at least 100 items.",
severity: validations.Severity.WARNING,
target: {
other: {
name: validations.NameInOther.OTHER_DEFAULT,
},
},
},
],
};
},
});Manual Setup Required
None — confirmed live. Once the app is installed and released, Wix calls this plugin automatically on every cart/checkout calculation; no dashboard configuration or extra API call is needed to "turn it on."
Key Implementation Notes
- Return empty array when valid - Return
{ violations: [] }when no validation issues - Use SDK enums - Use
validations.Severityandvalidations.NameInOtherfor proper values - Clear messages - Write descriptive
descriptiontext that helps customers fix the issue - ERROR vs WARNING - Use ERROR to block checkout, WARNING to inform but allow proceeding
- Target specificity - Use
other.namefor cart-wide validations,lineItem._idfor item-specific issues