Skip to content

Instantly share code, notes, and snippets.

@esitefinity
Created May 24, 2012 05:34
Show Gist options
  • Save esitefinity/2779669 to your computer and use it in GitHub Desktop.
Save esitefinity/2779669 to your computer and use it in GitHub Desktop.
Sitefinity Ecommerce - Pre-purchasing processing hook
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Modules.Ecommerce;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
}
void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
{
if (e.CommandName == "Bootstrapped")
{
EcommerceEvents.PreProcessOrder += new EcommerceEvents.OnPreProcessOrder(EcommerceEvents_PreProcessOrder);
}
OrderValidator EcommerceEvents_PreProcessOrder(Guid cartOrderId, CheckoutState checkoutState, Customer customer)
{
bool isOrderValid = DateTime.Now.Second % 2 == 0;
OrderValidator orderValidator = new OrderValidator
{
IsOrderValid = isOrderValid,
StatusMessage = "Order failed because of my custom rule"
};
return orderValidator;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment