diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 915e9a439f0..89fc2030941 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -2070,12 +2070,7 @@ abstract class WC_Abstract_Order { wp_update_post( array( 'ID' => $this->id, 'post_status' => 'wc-' . $new_status ) ); $this->post_status = 'wc-' . $new_status; - // Get the order status label. - $order_statuses = wc_get_order_statuses(); - $old_status_label = isset( $order_statuses[ 'wc-' . $old_status ] ) ? strtolower( $order_statuses[ 'wc-' . $old_status ] ) : $old_status; - $new_status_label = isset( $order_statuses[ 'wc-' . $new_status ] ) ? strtolower( $order_statuses[ 'wc-' . $new_status ] ) : $new_status; - - $this->add_order_note( trim( $note . ' ' . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), $old_status_label, $new_status_label ) ) ); + $this->add_order_note( trim( $note . ' ' . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), strtolower( wc_get_order_status_label( $old_status ) ), strtolower( wc_get_order_status_label( $new_status ) ) ) ) ); // Status was changed do_action( 'woocommerce_order_status_' . $new_status, $this->id ); diff --git a/includes/wc-order-functions.php b/includes/wc-order-functions.php index ead5195e858..6fa65567b55 100644 --- a/includes/wc-order-functions.php +++ b/includes/wc-order-functions.php @@ -31,6 +31,22 @@ function wc_get_order_statuses() { return apply_filters( 'wc_order_statuses', $order_statuses ); } +/** + * Get the order status label. + * + * @since 2.2 + * @param string $status + * @return string + */ +function wc_get_order_status_label( $status ) { + $order_statuses = wc_get_order_statuses(); + + $status = str_replace( 'wc-', '', $status ); + $status = isset( $order_statuses[ 'wc-' . $status ] ) ? $order_statuses[ 'wc-' . $status ] : $status; + + return $status; +} + /** * Main function for returning orders, uses the WC_Order_Factory class. *