POST

Get Validation Violations


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

This method retrieves validation violations from your app.

Wix calls this method when certain actions are performed on a visitor's cart and checkout. For example, when an item is added to the cart, or when a coupon is added to a checkout. This method validates a visitor's cart and checkout, and returns any validation violations (using the structure provided by Wix eCommerce). Site visitors can see the validation violations in their cart and checkout pages. If there aren't any validation violations, the method returns an object containing an empty list.

Notes:

  • Do not call the Estimate Cart Totals, Estimate Current Cart Totals or Get Checkout methods from your implementation code for Get Validation Violations. Doing so will result in an error.
  • By default, this method only retrieves validation violations from a visitor's checkout. If you want to also retrieve validation violations from a visitor's cart, set the validateInCart parameter to true in the Ecom Validations Integration's config file.
Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Restaurants - all permissions
Learn more about app permissions.
Endpoint
POST
{DEPLOYMENT-URI}/v1/get-violations
Body Params
sourceInfoSourceInfo

Information about the source of the request.


validationInfoValidationInfo

Information to validate.

Response Object
violationsArray <Violation>

List of validation violations.

Get Validation Violations
Request
cURL
curl -X POST https://provider.example.com/v1/get-violations \ -H 'user-agent: Wix' \ -H 'accept-encoding: gzip, deflate' \ -H 'content-type: text/plain; charset=utf-8' \ -d '{ sourceInfo: { source: 'CART', purchaseFlowId: 'a22ebad0-11ef-4a4d-a567-691fa7cb264c' }, validationInfo: { appliedDiscounts: [ { lineItemIds: [], discountType: 'GLOBAL', coupon: { id: '435409da-d374-4c44-b08b-6c703c546960', code: 'couponCode', name: 'couponName' } } ], billingInfo: { address: { country: 'USA', subdivision: 'US-California', city: 'Los Angeles', postalCode: '123456' }, contactDetails: { firstName: 'John', lastName: 'Doe', phone: '12345678', company: 'Wix', vatId: { id: 'a35409de-d374-4c4b-bf8b-6c703c5b6960', type: 'CPF' } } }, buyerDetails: { contactId: 'f463b4ee-0545-45ac-a273-23bf02d38a07', email: 'Johnne@wix.com' }, customFields: { fields: [ { name: 'John', title: 'Name', translatedTitle: '名前' } ] }, giftCard: { id: 'e463b4ee-0145-45ac-a263-23bf02d38a07', appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e', amount: { amount: '2' } }, lineItems: [ { catalogReference: { appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e', catalogItemId: 'e35409da-d374-4c4b-b08b-6c703c5b6960' }, id: '00000000-0000-0000-0000-000000000001', itemType: { preset: 'PHYSICAL' }, physicalProperties: { shippable: true, sku: '', weight: 11 }, price: { amount: '1' }, productName: { original: 'Cute Silk Worm', translated: 'Cute Silk Worm' }, quantity: 4 }, { catalogReference: { appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e', catalogItemId: '74bfa1c0-ce2a-49b7-8cd8-a4c0e0b2af6e' }, id: '00000000-0000-0000-0000-000000000002', itemType: { preset: 'PHYSICAL' }, physicalProperties: { shippable: true, sku: '', weight: '12' }, price: { amount: '600' }, productName: { original: 'Tea Leaves', translated: 'Tea Leaves' }, quantity: 50 } ], priceSummary: { additionalFees: { amount: '0' }, discount: { amount: '0' }, shipping: { amount: '0.41' }, subtotal: { amount: '3.72' }, tax: { amount: '0.87' }, total: { amount: '5.00' } }, shippingAddress: { address: { country: 'USA', subdivision: 'US-California', city: 'Los Angeles', postalCode: '123456' }, contactDetails: { firstName: 'John', lastName: 'Doe', phone: '12345678', company: 'Wix', vatId: { id: 'a35409de-d374-4c4b-bf8b-6c703c5b6960', type: 'CPF' } } }, shippingInfo: { selectedCarrierServiceOption: { code: '8d782b64-bda4-93f6-d9c4-e40b497b0ec3' }, weightUnit: 'KG' } } }'
Response
JSON
{ "violations": [ { "description": "You must purchase at least 100 items.", "severity": "WARNING", "target": { "other": { "name": "OTHER_DEFAULT" } } } ] }
Did this help?