I would like to hook up to an event that fires when a customer clicks on the button "Place Order", do some validations and then decide whether to proceed with checkout (and payment) or not. If not, I'd like to cancel the order placement, but keep the items in the cart (quote hasn't been converted to order yet) and throw a message like "Your order could not be processed".
I hooked to the
checkout_submit_all_after event, which fires when I click on the button. I raised an exception and just got a browser alert "undefined" and remained in the page. I checked my account and the order was placed. So I added this:
This cancels the order so that it is not placed, but the cart is emptied and I get no feed back on what went wrong during checkout. Instead I'm redirected to the cart page with the message "No items in your cart".
tldr: I want to be able to validate an order before saving it, so that it can be cancelled displaying a message similar to the one that appears when the payment method fails ("Your order could not be processed").