Extension Point: Validate Shopping Item at Remove from Cart
Basics
Parameter | Value |
---|---|
Extension Point Key | VALIDATE_SHOPPING_ITEM_AT_REMOVE_FROM_CART |
Extension Point Name | Validate Shopping Item at Remove from Cart |
Extension Interface | ShoppingItemValidator |
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 items from being removed from the shopping cart.
Methods
validate
The validate
method is invoked when an item is being removed from the shopping cart. In Cortex, this happens when a DELETE operation is executed against the shopping cart line entity. 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_ITEM_AT_REMOVE_FROM_CART, priority = 100)
public class BlockingShoppingItemValidator extends XPFExtensionPointImpl implements ShoppingItemValidator {
@Override
public Collection<XPFStructuredErrorMessage> validate(final XPFShoppingItemValidationContext context) {
List<XPFStructuredErrorMessage> results = new ArrayList<>();
results.add(new XPFStructuredErrorMessage("block-remove-from-cart", "Always block remove-from-cart.", Collections.emptyMap()));
return results;
}
}