Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move EVENT_AFTER_ORDER_PAID back to after order marked as complete and paid #670

Closed
emilyfitton opened this issue Jan 30, 2019 · 4 comments

Comments

@emilyfitton
Copy link

Description

The change to the setup in here:
80f0f1c
Now means that this event is firing before the order is marked as complete and whilst isPaid is still false.

In practice this means that its not possible for a plugin to change the order status of an order after the order is completed.

Steps to reproduce

  1. Trigger event to change order status to a custom status
  2. Order status is changed to custom status then back to the default status.

Additional info

  • Craft version: 3.1.2.2
  • PHP version: 7.2.2
  • Database driver & version: 5.7.19
  • Plugins & versions: Commerce Pro 2.0.1
@lukeholder
Copy link
Member

Hi @emilyfitton not sure I understand, couldn't you use the Order::EVENT_AFTER_COMPLETE_ORDER event? Will re-open with response.

@emilyfitton
Copy link
Author

Yep so I can run Order::EVENT_AFTER_COMPLETE_ORDER and check the order is Paid.

However the docs imply that EVENT_AFTER_ORDER_PAID should run when an order is paid and complete.

This event is raised after an order is paid and completed

Plugins can get notified after an order is paid and completed

However in practice what I have found is that when using this event $order->getIsPaid() is returning false as is $order->isCompleted.

@andris-sevcenko
Copy link
Contributor

Hey @emilyfitton

After digging around the code a bit I think I understand your frustration. In broad strokes you are right. The commit you reference, though, was also wrong, because the event was nested inside the conditionals that also checked if the order was getting completed and some gateway payment flows dictated that sometimes an order would get completed first and paid a bit later, so before that commit was made, the EVENT_AFTER_ORDER_PAID was sometimes not fired.

We'll talk about this internally and, if everything seems to be safe with moving that event to after the order is being completed on that request, we'll do so.

@emilyfitton
Copy link
Author

No problem, its not holding anything up on my end as like you said I can use EVENT_AFTER_COMPLETE_ORDER for now. Just thought it was worth raising what I found along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants