To persist the get the values of the custom fields, you have to use the EcommerceCheckoutPageChanging event. It occurs every time the user navigates between the steps of the Checkout widget. In the handler for this event you can get instances of the UI controls for the fields and their values. You subscribe to this event in the Global.asax file. For more information about how to subscribe to this event and its event arguments, see the For development: IEcommerceCheckoutPageChanging event article.
The code for getting and persisting the values of the custom fields, is going to be placed in the handler for the EcommerceCheckoutPageChanging event.To get the values of the fields and persist them in the CartOrder instance, perform the following:
NOTE: Ensure to look for the respective field control only in the corresponding checkout step. It is important to perform this check because of the way the checkout pages are constructed. In some cases you may be able to find the control in a step even when it is actually in another step. In this case you may end up retrieving the wrong value from the control and thus persisting wrong data. Therefore, it is safest to verify the step whenever you save data from a control.
NOTE: The second argument accepted by the GetControl method is of type boolean and indicates whether the control should be treated as required or not. If the control is required and cannot be found, the method will throw an exception. If the control is not required and it does not exist, the method will return null.
NOTE: Information about creating this property can be found in the For developers: Create the custom fields for the CartOrder and Order classes article.
Use the following code sample:
NOTE: The code snippet above also contains the code form the previous article – For developers: Create the custom fields for the CartOrder and Order classes.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important