Promotions not applied
Closed this issue · 4 comments
Issue Overview
On https://github.com/eventespresso/eventsmart.com-website/pull/150#issuecomment-420855527 Seth discovered sometimes promotions don't get applied.
See
Here's the scoop: if you FIRST select the Smart Buttons payment method and THEN apply the discount, you pay the correct (discounted) amount. BUT if you apply the discount first and THEN select Smart Buttons payment method, you'll pay the wrong (non-discounted) amount.
Bug report or feature request?
- Bug
- Feature
- Neither
Environment Data:
Version of EE core: 4.9.68.p
Version of this addon:1.0.1
Version of WordPress:4.9.9
PHP Version: 7.1
Browser used: firefox 63.0b5
Steps to Reproduce (for bugs)
see original description
Expected Behaviour
promotions should always get applied
Current Behaviour
described above
Related Information:
The problem here is that if you apply the promotion before selecting the payment method, the JS listener (which listens for payment changes) isn't setup yet, so it's not around to detect the price change. And it just uses the payment amount set on pageload (which is now incorrect).
I was thinking it would be nice to instead just use whatever is set in SPCO.payment_amount
, as one would think that's the authorotative amount to pay. But I found that does NOT get updated when a promotion is applied (which was really strange), and is actually set to 0 when the page is reloaded when the page is the payment options steps. So it might be nice to make that consistently usable, but right now we can't depend on it.
So I think we should setup the payment amount listener as soon as the payment options step is setup, not just when this payment method is selected (the rest of the initialization process may need to still wait).
@mnelson4 is this issue fixed? I haven't noticed in recent testing.
yes the PR was merged into master so this issue is fixed (I forgot to update this issue and/or connect it). If you're still experiencing this issue feel free to reopen