Problem/Motivation
An "order paid in full" event has been added in 2.10 (see #2856586: Add an "order paid" event).
That event is triggered from the order doPreSave method and rely on isPaid() to check triggering. However, this method itself relies only on checking order balance, which lead "order paid in full" event to be triggered as soon as the order balance goes to 0, which not be when the customer has actually paid or even ordered.
Reproduction step
You will need a promotion of the type "100% off total order" and a coupon, let's call it "FREE" for that promotion.
You will also need the "coupon redemption" pane to be added on your order process: lateral bar is by default.
- Add a product to cart worth non 0 dollars
- Validate your cart and enter the order process
- When available enter the FREE coupon: the order balance now goes to 0$
The order paid in full event is triggered here but should not
- Change your mind, remove the coupon, whatever. From here, the event has been sent, maybe the customer received a receipt or whatever process was attached to an order he did not actually made at that point.
Remaining tasks
Proposal 1: Change the isPaid() method to also check total_paid is not zero
Cons: We cannot rely on this event for anything that has to be done for each order - for instance, a confirmation email - because it won't get sent for order with no payment associated (either no payment module activated, or FREE coupon for instance)
User interface changes
None
API changes
Probably not !
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3008175-5.patch | 2.84 KB | bojanz |
| #3 | order_paid_event_sent_wrong--3008175-3.patch | 611 bytes | dom. |
Comments
Comment #2
dom. commentedComment #3
dom. commentedAttached is a patch with the proposed solution.
However: that make the event NOT being sent for order worth 0. I am a bit confused at is it what we want ? Should the event be sent ONCE and only one per order, whatever the value of it ?
Comment #4
bojanz commentedEDIT: I was overthinking this.
All we need to do is add the following rule:
- If the order is free, it will be considered fully paid after it has been placed.
This allows the "order paid" event to be automatically triggered for free orders, once checkout is complete.
It also makes sense conceptually (the order dashboard should not say "Unpaid" for a placed free order).
Comment #5
bojanz commentedHow does this look?
Comment #7
bojanz commentedCommitted. Thanks for testing the event!