Skip to main content

Client-side events

In order to provide a better customer experience you can listen to custom client-side events and take appropriate action. All events are dispatched using the global document object as target and cannot be cancelled and does not bubble.

Please Note

Do not rely on client-side events for business critical functionality. Use the api to retrieve information. For example:

  1. Instead of relying only on walleyCheckoutPurchaseCompleted, listen for the Completed Purchase callback.
  2. When receiving a walleyCheckoutCustomerUpdated, get checkout information of what has been updated.

Javascript examples​

// Start listening to the customer updated event
document.addEventListener("walleyCheckoutCustomerUpdated", listener);

// Start listening to the locked event
document.addEventListener("walleyCheckoutLocked", listener);

// Start listening to the unlocked event
document.addEventListener("walleyCheckoutUnlocked", listener);

// Start listening to the resumed event
document.addEventListener("walleyCheckoutResumed", listener);

// Start listening to the purchase completed event
document.addEventListener("walleyCheckoutPurchaseCompleted", listener);

// Start listening to the shipping updated event
document.addEventListener("walleyCheckoutShippingUpdated", listener);

// Start listening to the CRM updated event
document.addEventListener("walleyCheckoutCrmUpdated", listener);

// Start listening to the validation failed event
document.addEventListener("walleyCheckoutOrderValidationFailed", listener);

Description of available events​

EventDescription
walleyCheckoutCustomerUpdatedOccurs when the Checkout client-side detects any change to customer information, such as a changed email, mobile phone number or delivery address. This event is also fired the first time the customer is identified.
walleyCheckoutLockedOccurs when no user input should be accepted, for instance during processing of a purchase.
walleyCheckoutUnlockedOccurs after a locked event when it is safe to allow user input again. For instance after a purchase has been processed (regardless of whether the purchase was successful or not).
walleyCheckoutResumedOccurs when the Checkout has loaded new data and is back in its normal state after a suspend. See section Client-side API for more details.
walleyCheckoutPurchaseCompletedOccurs when the purchase has been completed.
walleyCheckoutShippingUpdatedOnly available when Delivery Module is used. Indicates that the delivery selection has changed.
walleyCheckoutCrmUpdatedOnly available when CRM Module is used. Occurs when the customer has changed any information for the CRM module, such as toggling to apply for membership.
walleyCheckoutOrderValidationFailedOccurs when order validation returns a non-2XX response. If a clientPayload object is returned in the validation response, it is sent as a payload parameter here. This can be useful if the client-side code needs information about why the validation failed.