Extension Point: Validate Shopping Cart at Cart Create or Update
Basics
Parameter | Value |
---|---|
Extension Point Key | VALIDATE_SHOPPING_CART_AT_CART_CREATE_OR_UPDATE |
Extension Point Name | Validate Shopping Cart at Cart Create or Update |
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 custom shopping carts from being created or prevent the cart descriptors on an existing shopping cart from being updated.
note
This Extension Point is not invoked when a shopper’s default shopping cart is created.
Methods
validate
The validate
method is invoked when a custom shopping cart is being created or when a shopping cart’s descriptors are being updated. In Cortex, this happens when a client submits the new shopping cart form (with a POST
operation) or when a client updates an existing shopping cart entity (with a PUT
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.
Extension Sample
@Extension
@XPFAssignment(extensionPoint = XPFExtensionPointEnum.VALIDATE_SHOPPING_CART_AT_CART_CREATION, 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;
}
}