Extension Point: Validate Shopping Cart at Checkout
Basics
Parameter | Value |
---|---|
Extension Point Key | VALIDATE_SHOPPING_CART_AT_CHECKOUT |
Extension Point Name | Validate Shopping Cart at Checkout |
Extension Interface | ShoppingCartValidator |
Supports Multiple Extensions? | Yes |
Selector Type | Store |
Available Since | 1.0.0 |
Use Cases
Extensions implementing this Extension Point can enforce business rules that prevent shopping carts from being purchased.
Methods
validate
The validate
method is invoked during checkout. In Cortex, this happens when the cart order resource is read (with a GET
operation), when the purchase form resource is read (with a GET
operation), and when the purchase form is submitted (with a POST
operation).
For the GET
operations, if one or more extensions returns StructuredErrorMessage
objects, then the action link is omitted, and the error message details are returned in the "messages" section of the response so that the shopper can understand why the cart can’t be purchased.
For the POST
operation, if one or more extensions returns StructuredErrorMessage
objects, then a 400 BAD REQUEST
response is returned, and the error message details are returned in the response body so that the shopper can understand why the cart can’t be purchased.
note
The Validate Product Sku at Checkout and Validate Shopping Cart at Checkout Extension Points are invoked at the same time as this Extension Point.
Extension Sample
@Extension
@XPFAssignment(extensionPoint = XPFExtensionPointEnum.VALIDATE_SHOPPING_CART_AT_CHECKOUT, priority = 100)
public class BlockingShoppingCartValidator extends XPFExtensionPointImpl implements ShoppingCartValidator {
@Override
public Collection<XPFStructuredErrorMessage> validate(final XPFShoppingCartValidationContext xpfShoppingCartValidationContext) {
List<XPFStructuredErrorMessage> results = new ArrayList<>();
results.add(new XPFStructuredErrorMessage("block.shopping.cart", "Always block shopping cart from being created or purchased.", Collections.emptyMap()));
return results;
}
}