Keine Beschreibung

my-orders.php 3.7KB

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