getValidationViolations( )


Retrieves any validation violations in a site visitor's cart or checkout.

The getValidationViolations function validates a site visitor's cart or checkout and returns any validation violations. Site visitors can see the validation violations in their cart and checkout pages. If there aren't any validation violations, the endpoint returns an object containing an empty list.

The function is automatically called by Wix eCommerce when certain actions are performed on a cart or checkout. For example, when an item is added to a cart, or when a coupon is added to a checkout.

Note: 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.

Where to find getValidationViolations()

When you add the Validations service plugin, a folder is automatically added to your site. Use the .js file in the folder to write the code to determine which validation violations to retrieve.

For more information on customizing your checkout validations plugin, see Tutorial: Validations Service Plugin.

Method Declaration
Copy
Method Parameters
optionsOptionsRequired

Validation options.


contextContextRequired

Metadata about the request.

Returns
Return Type:Promise<GetValidationViolationsResponse>
Did this help?