Preorder Validation

This section explains how the order is validated by Litium.

Validation rules for the Litium platform - Non-changeable

  • Validating that the cart has any products.
  • Validating that the selected shipping option is valid for the country and channel combination.
  • Validate that the cart only contains valid discount codes.
  • Validating that the discount not have been changed.
  • Validating that the selected payment option is valid for the country and channel combination.
  • Validating that the field limits of the address entity not is exceeded.
  • Validating that the price not have been changed for a product.

Validation rules for the Accelerator - Changeable

  • ProductIsAvailableForSale - Validating that the product exists and has a price for the selected channel and currency.
  • ProductsAreInStock - Validating that the product exists in stock.

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;