I'm assuming the event is what is breaking this function, but it may be the page redirect. The expected function is to redirect a customer back to the cart and display a warning message. I opened a new issue since this may now be a bug and not a feature request. If See #1233508: Checkout display as rules event.

Comments

essbee’s picture

Confirmed also seeing this bug. Even with the redirect removed the message is not displayed, thus indeed suggesting it is an issue with the event.

Sam

rszrama’s picture

Nah, it's not an issue with the event - it's the way the checkout form itself operates is my guess. We trap messages specially and display them inline with their checkout panes, but that event gets called during the form building process during which I believe messages may be lost.

TyrelDenison’s picture

How then could I invoke a warning message on the page I redirect to with rules?

rszrama’s picture

Not sure yet. I'm guessing the checkout form builder just needs to accommodate messages being displayed during the form building process.

dpolant’s picture

StatusFileSize
new2.71 KB

The problem seems to be that commerce_checkout_form clears the system messages queue when it attempts to render messages inline for each pane. Thus the messages are not there by the time the user lands on the page specified by the rules redirect.

Fortunately, rules sets a global variable to remind itself to do the redirect after the pages are fully built. It is possible to use this and conditionally prevent the checkout form builder from doing things that clear the message queue.

First-pass patch provided (it is against dev, where this problem does persist).

TyrelDenison’s picture

The patch worked great for me. Thanks so much.

rszrama’s picture

Are we sure the solution needs to be tied specifically to the Rules redirect? It's feasible that modules might also directly be adding messages that we wouldn't want to be wiped out. I've been bitten by that before when I've tried to dump debug data out in a checkout form builder function.

dpolant’s picture

I was able to use dpm successfully inside the checkout form pane callback and inside commerce_checkout_form, both before and after the message queue clear/render. Any ideas on how to reproduce the message-loss issues you experienced before? It worked for me on a few different checkout pages.

I think the rules redirect issue may be separate from the problem where messages added on the same page-load by other modules are not displaying. The key to preventing redirection-message-loss is knowing when a redirect is going to happen and telling commerce_checkout_form's message renderer not to clear the queue. Without looking at whether a redirect is going to happen, we don't know whether messages should persist into the next page load or whether the queue should be cleared so that the user doesn't see them twice.

I was able to simplify the patch a bit.

essbee’s picture

Status: Active » Needs review

Great patch. Two lines of code and all is as expected.

Works great for me.

rszrama’s picture

Status: Needs review » Fixed

Finally had a chance to review the patch, and it works exactly as expected. I was probably just remembering the other issues from before we updated message handling in the checkout form. Will keep an eye out but glad to fix the immediate issue with this patch. Thanks, Dan. : )

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.