bossanova808 / CommerceRegisterOnCheckout

ARCHIVED: SEE README Allow user registration during Craft Commerce V1 checkouts.
Other
33 stars 3 forks source link

Clarify registered state #15

Closed jmauzyk closed 6 years ago

jmauzyk commented 6 years ago

Hey, thanks for all your work on this plugin! I noticed a couple things that weren't working great for me and tried adjusting a few things.

Currently Register On Checkout is returning an empty string for both failed registration attempts and orders where no registration was attempted. This can make it difficult at times to accurately display the correct results message.

The updated code searches for a boolean value and returns it if one is found, otherwise it returns null. Null allows for clearer comparison in twig since testing a variable's length or if it is null can produce the same result for a false boolean value and an empty string. This way, testing if registered is null will prevent any messages from displaying when no registration was attempted.

I also added the clearRegisterSession function which can be called by a twig do tag after the register status and account have been stored in variables. This way the result messages can be displayed after checkout, but the httpSession variables can be cleared manually so you don't have to wait for the user session to expire for the messages to stop displaying on future requests.

Let me know what you think!

bossanova808 commented 6 years ago

Seems all sensible to me! I'm waiting on another PR but will merge this in and do a release soon...

jmauzyk commented 6 years ago

Excellent! Thanks much, @bossanova808!

bossanova808 commented 6 years ago

ok just did a release