IEcommerceCheckoutPageChanging event

This event occurs when the user navigates from one step to another in the Checkout widget. During these steps you can perform things like:

  • Work with custom fields that are added to the CartOrder object.
    For example, you can use custom fields in order to collect additional information (e.g. Gift Message) during the checkout process. These values are stored as custom fields of the CartOrder and Order objects. To provide an input for these fields, you modify the templates of the checkout widget. The only place where you can get the input for the fields and store it in the database is the EcommerceCheckoutPageChanging event. For a detailed example of this scenario, read the For developers: Add custom fields to the Checkout widget.
  • Perform additional validation checks using hooks into their ERP or Inventory system.
  • Pull or push data to their CRM.

The argument is of type Telerik.Sitefinity.Modules.Ecommerce.Events. IEcommerceCheckoutPageChangingEvent. It has the following specific members:

  • Container
    Represents an instance of the GenericContainer for the current step. It contains instances of the controls in the template for the current step.
  • CurrentStepIndex
    Represents the number of the step. You can use this value to determine the current step. The order of the steps is as follows:
    • Shipping information – 0
    • Shipping options – 1
    • Payment – 2
    • Preview – 3

      When there is no product that requires shipping, the Shipping options step is hidden and the indexes are as follows:
      • Shipping and billing information – 0
      • Payment – 1
      • Preview – 2
  • ShoppingCartId
    Represents the ID of the shopping cart that is currently used by the customer. Using this ID you can get instance of the cart and perform changes to the information in it.
  • UserId
    Represents the ID of the user that is currently performing the checkout. Based on this ID you can get instance of the customer or the user and gather additional information about them.

To hook up to this event, you must perform the following:

  • Handle the Initialized event of the Bootstrapper.
    For more information, read For developers: Ecommerce events.
  • Subscribe to the event.
    In the handler for the Bootstrapped event of the Bootstrapper, subscribe to the event using the Subscribe static method of EventHub class. As generic argument pass IEcommerceCheckoutPageChangingEvent, and as the handler argument pass the method to handle the event.

Use the following code sample:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?