Skip to main content
Version: 1.1.x

Extension Point: Validate Shopping Cart at Checkout

Basics​

ParameterValue
Extension Point KeyVALIDATE_SHOPPING_CART_AT_CHECKOUT
Extension Point NameValidate Shopping Cart at Checkout
Extension InterfaceShoppingCartValidator
Supports Multiple Extensions?Yes
Selector TypeStore
Available Since1.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 (GET), when the purchase form resource is read (GET), and when the purchase form is submitted (POST).

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;
}
}