Skip to main content

onBeforeCheckout

@combeenation/custom-code-utils


Function: onBeforeCheckout()

onBeforeCheckout(listener, timeoutMS?): void

Execute tasks before the actual checkout. Optionally the checkout can also be cancelled.
The checkout is waiting until all listeners are finished or the timeout has elapsed.

Parameters

listener

OnBeforeCheckoutListener

The function to be executed.
If any listener returns false it will cancel the checkout.

timeoutMS?

number

Timeout value in ms.
When running into the timeout it will proceed with the checkout and not cancel it!
If it should cancel, it has to be implemented in the listener itself.

Returns

void

Example

CfgrUtils.onBeforeCheckout(async ({ shopInput }) => {
if (shopInput !== 'Save') {
const success = createFinalPdf();
if(!success) {
showErrorNotification();
return false; // prevent checkout
}
}
});