diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index 9593e573570..fafa8fd2dbe 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -371,6 +371,21 @@ class WC_Order extends WC_Abstract_Order { do_action( 'woocommerce_order_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); do_action( 'woocommerce_order_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); + + // Work out if this was for a payment, and trigger a payment_status hook instead. + if ( + in_array( $status_transition['from'], apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ) ), true ) + && in_array( $status_transition['to'], wc_get_is_paid_statuses(), true ) + ) { + /** + * Fires when the order progresses from a pending payment status to a paid one. + * + * @since 3.9.0 + * @param int Order ID + * @param WC_Order Order object + */ + do_action( 'woocommerce_order_payment_status_changed', $this->get_id(), $this ); + } } else { /* translators: %s: new order status */ $transition_note = sprintf( __( 'Order status set to %s.', 'woocommerce' ), wc_get_order_status_name( $status_transition['to'] ) );