Setting the file. One moment.
Subchapter 2.80
references/service-plugin/VALIDATIONS.mdMarkdown2 KBView on GitHub
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.
Before implementing, call ReadFullDocsMethodSchema on the docs URL to get the full request/response types.
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,
},
},
},
],
};
},
});{ violations: [] } when no validation issuesvalidations.Severity and validations.NameInOther for proper valuesdescription text that helps customers fix the issueother.name for cart-wide validations, lineItem._id for item-specific issues