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

Comments

Dom. created an issue. See original summary.

dom.’s picture

Issue summary: View changes
dom.’s picture

Status: Active » Needs review
StatusFileSize
new611 bytes

Attached 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 ?

bojanz’s picture

Assigned: Unassigned » bojanz

EDIT: 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).

bojanz’s picture

Title: "Order paid in full" event is triggered wrong » "Order paid" event is not triggered correctly for free orders
StatusFileSize
new2.84 KB

How does this look?

  • bojanz committed 0a40ae4 on 8.x-2.x
    Issue #3008175 by Dom., bojanz: "Order paid" event is not triggered...
bojanz’s picture

Status: Needs review » Fixed

Committed. Thanks for testing the event!

Status: Fixed » Closed (fixed)

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