You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating an order with a status change via the REST API, the new order information is not stored until after the status has changed, causing old order data to be used in the status change hooks.
Example
When an order is shipped, I'm updating the order via REST with the new completed status and the tracking information as metadata fields.
In a plugin I have installed a filter for woocommerce_email_order_meta_fields that adds the tracking info meta fields so they appear in the order complete email. Unfortunately these metadata values are not present so they don't appear in the email.
Only after the order status is updated and the email is sent, is all the other order data actually updated.
When I then re-send the email via the Edit Order page, the tracking information is displayed correctly.
Workaround
For now it seems that changing the order status must be done separately from any other changes. This means two REST calls per order instead of one.
Thanks again for your time!
The text was updated successfully, but these errors were encountered:
When updating an order with a status change via the REST API, the new order information is not stored until after the status has changed, causing old order data to be used in the status change hooks.
Example
When an order is shipped, I'm updating the order via REST with the new
completed
status and the tracking information as metadata fields.$order->update_status()
is called, which invokes the status change hooks that send thecustomer-completed-order.php
email.woocommerce_email_order_meta_fields
that adds the tracking info meta fields so they appear in the order complete email. Unfortunately these metadata values are not present so they don't appear in the email.When I then re-send the email via the Edit Order page, the tracking information is displayed correctly.
Workaround
For now it seems that changing the order status must be done separately from any other changes. This means two REST calls per order instead of one.
Thanks again for your time!
The text was updated successfully, but these errors were encountered: