In order to store the values entered in the UI fields that you have created in the previous step, you have to create custom fields for the CartOrder and Order objects. During the checkout process a CartOrder object is used to gather the information and preserve it in the database.
NOTE: Ecommerce order data is stored in multiple tables. During the checkout process this data is stored in “Cart” tables. These tables act like a temporary buffer to hold all of the information that a customer will enter during the multiple step check out process (shipping address, billing address, selected shipping method, payment method, coupon codes, etc.). Once a customer chooses to actually purchase the items in their cart, the contents of the “Cart” tables are then copied to the similarly named “Order” tables.
Because you will only want to attempt to modify the database structure once, a good place to perform this action is in the Application_Start event handler in the Global.asax file. By default, a new SitefinityWebApp project does not include this file so you will need to add a new Global.asax file to your project. In the Application_Start handler, hook up to the Initialized event of the Bootstrapper class. This event occurs when the first instance of your Sitefinity CMS site is requested. The code in this example is executed only when the CommandName value of the event arguments is equal to ”Bootstrapped”.
To create the fields, you will be using a method named CreateCustomOrderFields(). This method must perform the following:
To create the custom fields for the CartOrder and Order objects, you must perform the following.
Here is how your code must look like:
Global : System.Web.HttpApplication
sender, EventArgs e)
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
// You need an instance of the MetadataMananger in order to add the new meta field to the tables.
MetadataManager metaManager = MetadataManager.GetManager();
// Check if the Order table has already been modified to contain meta fields
// Create the metatype for the order class.
// Save the changes
// Add a new meta field to the Order table
// Check if the CartOrder table has already been modified to contain meta fields
// Create the metatype for the CartOrder class.
//Save the changes.
// Add a new meta field to the CartOrder table
Back To Top