On WooCommerce plugin, if merchant enables webhook configuration, sometimes they can see the order status updated twice and gets 2 email notification for the same order.
This issue happens as callback action after payment and webhook executes concurrently, updating notes and order status at the same time causing sending email notification twice.
Using worker queue for a function $order->payment_complete() which makes sure it to execute one after the other.
3. Quality assurance
🔧 Environments:
i.e.
WooCommerce: v4.0.1
WordPress: v5.4.2
PHP version: 7.2.1
Omise plugin version: Omise-WooCommerce 3.11 (optional, in case of submitting a new issue)
✏️ Details:
Steps to reproduce:
Add product to cart.
Checkout using Card payment.
Place order and complete the payment process
Go to customers email account and check email.
Go to Wordpress backend >> WooCommerce >> Orders >> Check order notes.
Actual behaviour:
After order completion, duplicate(twice) emails gets sent to customer for order comfirmation, Duplicate notes attached to order. This happens intermittently.
Expected behaviour:
After order completion, no duplicate order email should get sent to customer and no duplicate note should get added to
1. Objective
On WooCommerce plugin, if merchant enables webhook configuration, sometimes they can see the order status updated twice and gets 2 email notification for the same order.
This issue happens as callback action after payment and webhook executes concurrently, updating notes and order status at the same time causing sending email notification twice.
Duplicate notes:
Related information: Internal Ticket(s): https://phabricator.omise.co/T22125
2. Description of change
$order->payment_complete()
which makes sure it to execute one after the other.3. Quality assurance
🔧 Environments: i.e.
✏️ Details: Steps to reproduce:
Actual behaviour: After order completion, duplicate(twice) emails gets sent to customer for order comfirmation, Duplicate notes attached to order. This happens intermittently.
Expected behaviour: After order completion, no duplicate order email should get sent to customer and no duplicate note should get added to
4. Impact of the change
Card payment should work normally
5. Priority of change
High.
6. Additional Notes
Using following solution suggested by @guzzilar https://gist.github.com/thenbrent/974053a348eb7f3ea4c4cb827a39d2e7