How to implement a new validation rule when placing an order

Example: we need to validate if the product is available for Sales

Create class ProductIsAvailableForSale inherited from class ValidationRuleBase<ValidateCartContextArgs> and implement the logic of validating in the method Validate

using Litium.Sales;
using Litium.Validations;
using Litium.Web;

namespace Litium.Accelerator.ValidationRules
    /// <summary>
    /// Validates whether product is still available to buy, since it was last put to cart.
    /// </summary>
    public class ProductIsAvailableForSale : ValidationRuleBase<ValidateCartContextArgs>
        public ProductIsAvailableForSale()

        public override ValidationResult Validate(ValidateCartContextArgs entity, ValidationMode validationMode)
            var result = new ValidationResult();
            //implement logic for validating
            result.AddError("Cart", "sales.validation.product.nolongeravailableforsale".AsWebsiteText());

            return result;



If the ValidateCartContextArgs.ConfirmedCart property is not null, it contains the information from the payment app about the Cart which the payment app has.

This is usally the last validation call coming from the payment app.

The Cart in Litum should match the ConfirmedCart in article quantities and prices, otherwise it should be treated as a validation failure.

The ConfirmedCart may have additional payment fees rows, which is ok.