From 05b9b8af4ee0bf8750a819faabe2ed554cd66c8f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 30 May 2014 16:29:44 +0100 Subject: [PATCH] get_status_name + my_orders --- includes/class-wc-order.php | 13 +++++++++++-- templates/myaccount/my-orders.php | 13 +++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index 7857fd56049..3a147cf23ed 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -111,13 +111,22 @@ class WC_Order { } /** - * Return the order status - * @return string - pending, on-hold, processing, completed, cancelled, refunded + * Return the order statuses + * @return string */ public function get_status() { return $this->post_status; } + /** + * Return the order statuses formatted name + * @return string + */ + public function get_status_name() { + $statuses = wc_get_order_statuses(); + return isset( $statuses[ $this->post_status ] ) ? $statuses[ $this->post_status ] : ''; + } + /** * Checks the order status against a passed in status. * diff --git a/templates/myaccount/my-orders.php b/templates/myaccount/my-orders.php index 3edb8849539..58f9a06bc0b 100644 --- a/templates/myaccount/my-orders.php +++ b/templates/myaccount/my-orders.php @@ -18,7 +18,7 @@ $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_q 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => 'shop_order', - 'post_status' => 'publish' + 'post_status' => array_keys( wc_get_order_statuses() ) ) ) ); if ( $customer_orders ) : ?> @@ -39,11 +39,8 @@ if ( $customer_orders ) : ?> populate( $customer_order ); - - $status = get_term_by( 'slug', $order->status, 'shop_order_status' ); $item_count = $order->get_item_count(); ?> @@ -56,7 +53,7 @@ if ( $customer_orders ) : ?> - name, 'woocommerce' ) ); ?> + get_status_name(); ?> get_formatted_order_total(), $item_count ); ?> @@ -65,14 +62,14 @@ if ( $customer_orders ) : ?> status, apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) { + if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) { $actions['pay'] = array( 'url' => $order->get_checkout_payment_url(), 'name' => __( 'Pay', 'woocommerce' ) ); } - if ( in_array( $order->status, apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) { + if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) { $actions['cancel'] = array( 'url' => $order->get_cancel_order_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ), 'name' => __( 'Cancel', 'woocommerce' )