I’m not sure if we can do anything about this from our end. The PDF invoice plugin does not send the email, this is entitely handled by WooCommerce. We merely hook into this process to add the attachment.
When the order status is actually changed to the status you are after, depends on the way it is changed, which can be different ways depending on the payment gateway.
Normally though, it should already have the actual status, as our plugin always loads the ‘latest’ order data. Here’s a quick rundown of the process when completing an order:
$order->payment_complete()
is called
- WC sets order status via
$order->set_status()
(source) which in turn triggers $order->status_transition()
after saving
- the status transition triggers the
woocommerce_order_status_{$status_transition['to']}
hook which fires an additional hook from WooCommerce added here: woocommerce_order_status_{$status_transition['to']}_notification
.
- Each of these
_notification
hooks can be used to trigger an email, such as here: woocommerce_order_status_completed_notification
- Our plugin then hooks into the attachment process of that email, using the
woocommerce_email_attachments
filter (source)
- This filter gets the current/most up to date order object, but because order meta may not be fully up to date at that point (order status always will be!) because this may have been updated by other processes hooking into the same hook,
our plugin actively reloads the order object: we pass the order_id
(here) rather than the order object, which triggers a reload.
It should be clear from this rundown that under normal circumstances, our plugin hooks in way after the order is completed and always contains the latest available order data, but as I said, it’s possible that gateways have a different flow and confirm the order in two separate steps.
Hope that helps!