get_status_name + my_orders
This commit is contained in:
parent
334acf42f5
commit
05b9b8af4e
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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 ) : ?>
|
|||
|
||||
<tbody><?php
|
||||
foreach ( $customer_orders as $customer_order ) {
|
||||
$order = new WC_Order();
|
||||
|
||||
$order = new WC_Order();
|
||||
$order->populate( $customer_order );
|
||||
|
||||
$status = get_term_by( 'slug', $order->status, 'shop_order_status' );
|
||||
$item_count = $order->get_item_count();
|
||||
|
||||
?><tr class="order">
|
||||
|
@ -56,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>
|
||||
</td>
|
||||
<td class="order-status" style="text-align:left; white-space:nowrap;">
|
||||
<?php echo ucfirst( __( $status->name, 'woocommerce' ) ); ?>
|
||||
<?php echo $order->get_status_name(); ?>
|
||||
</td>
|
||||
<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 ); ?>
|
||||
|
@ -65,14 +62,14 @@ if ( $customer_orders ) : ?>
|
|||
<?php
|
||||
$actions = array();
|
||||
|
||||
if ( in_array( $order->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' )
|
||||
|
|
Loading…
Reference in New Issue