fixed wc_get_order_status_name() appear as wc 2.1 order status

This commit is contained in:
claudiosmweb 2014-09-12 10:01:49 -03:00
parent aee2b62c85
commit 066eb3c5b0
5 changed files with 15 additions and 25 deletions

View File

@ -2072,7 +2072,7 @@ abstract class WC_Abstract_Order {
wp_update_post( array( 'ID' => $this->id, 'post_status' => 'wc-' . $new_status ) ); wp_update_post( array( 'ID' => $this->id, 'post_status' => 'wc-' . $new_status ) );
$this->post_status = 'wc-' . $new_status; $this->post_status = 'wc-' . $new_status;
$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 ) ) ) ) ); $this->add_order_note( trim( $note . ' ' . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), wc_get_order_status_name( $old_status ), wc_get_order_status_name( $new_status ) ) ) );
// Status was changed // Status was changed
do_action( 'woocommerce_order_status_' . $new_status, $this->id ); do_action( 'woocommerce_order_status_' . $new_status, $this->id );

View File

@ -445,7 +445,7 @@ class WC_Admin_Post_Types {
switch ( $column ) { switch ( $column ) {
case 'order_status' : case 'order_status' :
printf( '<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title( $the_order->get_status() ), wc_get_order_status_label( $the_order->get_status() ), wc_get_order_status_name( $the_order->get_status() ) ); printf( '<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title( $the_order->get_status() ), wc_get_order_status_name( $the_order->get_status() ), wc_get_order_status_name( $the_order->get_status() ) );
break; break;
case 'order_date' : case 'order_date' :

View File

@ -31,26 +31,11 @@ function wc_get_order_statuses() {
return apply_filters( 'wc_order_statuses', $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. * Main function for returning orders, uses the WC_Order_Factory class.
* *
* @param mixed $the_order Post object or post ID of the order. * @since 2.2
* @param mixed $the_order Post object or post ID of the order.
* @return WC_Order * @return WC_Order
*/ */
function wc_get_order( $the_order = false ) { function wc_get_order( $the_order = false ) {
@ -58,13 +43,18 @@ function wc_get_order( $the_order = false ) {
} }
/** /**
* Get the nice name for an orer status * Get the nice name for an order status
*
* @since 2.2
* @param string $status * @param string $status
* @return string * @return string
*/ */
function wc_get_order_status_name( $status ) { function wc_get_order_status_name( $status ) {
$statuses = wc_get_order_statuses(); $statuses = wc_get_order_statuses();
return isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status; $status = 'wc-' === substr( $status, 0, 3 ) ? substr( $status, 3 ) : $status;
$status = isset( $statuses[ 'wc-' . $status ] ) ? $statuses[ 'wc-' . $status ] : $status;
return strtolower( $status );
} }
/** /**

View File

@ -53,7 +53,7 @@ if ( $customer_orders ) : ?>
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time> <time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
</td> </td>
<td class="order-status" style="text-align:left; white-space:nowrap;"> <td class="order-status" style="text-align:left; white-space:nowrap;">
<?php echo wc_get_order_status_label( $order->get_status() ); ?> <?php echo wc_get_order_status_name( $order->get_status() ); ?>
</td> </td>
<td class="order-total"> <td class="order-total">
<?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?> <?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>

View File

@ -2,7 +2,7 @@
/** /**
* View Order * View Order
* *
* Shows the details of a particular order on the account page * Shows the details of a particular order on the account page
* *
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php wc_print_notices(); ?> <?php wc_print_notices(); ?>
<p class="order-info"><?php printf( __( 'Order <mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_label( $order->get_status() ) ); ?></p> <p class="order-info"><?php printf( __( 'Order <mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_name( $order->get_status() ) ); ?></p>
<?php if ( $notes = $order->get_customer_order_notes() ) : <?php if ( $notes = $order->get_customer_order_notes() ) :
?> ?>
@ -40,4 +40,4 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php <?php
endif; endif;
do_action( 'woocommerce_view_order', $order_id ); do_action( 'woocommerce_view_order', $order_id );