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

[REST API] Order status change hook fires too soon #9672

Closed
neonics opened this issue Nov 21, 2015 · 0 comments
Closed

[REST API] Order status change hook fires too soon #9672

neonics opened this issue Nov 21, 2015 · 0 comments
Assignees
Milestone

Comments

@neonics
Copy link

neonics commented Nov 21, 2015

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.

  • First $order->update_status() is called, which invokes the status change hooks that send the customer-completed-order.php email.
  • 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!

@roykho roykho added the API label Nov 21, 2015
@roykho roykho changed the title Order status change hook fires too soon in REST API [REST API] Order status change hook fires too soon Nov 21, 2015
claudiosanches added a commit that referenced this issue Dec 1, 2015
@claudiosanches claudiosanches added this to the 2.4.11 milestone Dec 1, 2015
@claudiosanches claudiosanches self-assigned this Dec 1, 2015
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