my-orders.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * My Orders - Deprecated
  4. *
  5. * @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. $my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array(
  11. 'order-number' => __( 'Order', 'woocommerce' ),
  12. 'order-date' => __( 'Date', 'woocommerce' ),
  13. 'order-status' => __( 'Status', 'woocommerce' ),
  14. 'order-total' => __( 'Total', 'woocommerce' ),
  15. 'order-actions' => '&nbsp;',
  16. ) );
  17. $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
  18. 'numberposts' => $order_count,
  19. 'meta_key' => '_customer_user',
  20. 'meta_value' => get_current_user_id(),
  21. 'post_type' => wc_get_order_types( 'view-orders' ),
  22. 'post_status' => array_keys( wc_get_order_statuses() ),
  23. ) ) );
  24. if ( $customer_orders ) : ?>
  25. <h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent orders', 'woocommerce' ) ); ?></h2>
  26. <table class="shop_table shop_table_responsive my_account_orders">
  27. <thead>
  28. <tr>
  29. <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
  30. <th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
  31. <?php endforeach; ?>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. <?php foreach ( $customer_orders as $customer_order ) :
  36. $order = wc_get_order( $customer_order );
  37. $item_count = $order->get_item_count();
  38. ?>
  39. <tr class="order">
  40. <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
  41. <td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
  42. <?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
  43. <?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
  44. <?php elseif ( 'order-number' === $column_id ) : ?>
  45. <a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
  46. <?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
  47. </a>
  48. <?php elseif ( 'order-date' === $column_id ) : ?>
  49. <time datetime="<?php echo esc_attr( $order->get_date_created()->date( 'c' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time>
  50. <?php elseif ( 'order-status' === $column_id ) : ?>
  51. <?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?>
  52. <?php elseif ( 'order-total' === $column_id ) : ?>
  53. <?php
  54. /* translators: 1: formatted order total 2: total order items */
  55. printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count );
  56. ?>
  57. <?php elseif ( 'order-actions' === $column_id ) : ?>
  58. <?php
  59. $actions = wc_get_account_orders_actions( $order );
  60. if ( ! empty( $actions ) ) {
  61. foreach ( $actions as $key => $action ) {
  62. echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
  63. }
  64. }
  65. ?>
  66. <?php endif; ?>
  67. </td>
  68. <?php endforeach; ?>
  69. </tr>
  70. <?php endforeach; ?>
  71. </tbody>
  72. </table>
  73. <?php endif; ?>