created the wc_get_order_status_label() function

This commit is contained in:
claudiosmweb 2014-09-09 14:14:10 -03:00
parent c85a71dcee
commit 2f1533ff94
2 changed files with 17 additions and 6 deletions

View File

@ -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 );

View File

@ -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.
*