/templates/myaccount/orders.php

  1. <?php 
  2. /** 
  3. * Orders 
  4. * 
  5. * Shows orders on the account page. 
  6. * 
  7. * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php. 
  8. * 
  9. * HOWEVER, on occasion WooCommerce will need to update template files and you 
  10. * (the theme developer) will need to copy the new files to your theme to 
  11. * maintain compatibility. We try to do this as little as possible, but it does 
  12. * happen. When this occurs the version of the template file will be bumped and 
  13. * the readme will list any important changes. 
  14. * 
  15. * @see https://docs.woocommerce.com/document/template-structure/ 
  16. * @author WooThemes 
  17. * @package WooCommerce/Templates 
  18. * @version 3.0.0 
  19. */ 
  20.  
  21. if ( ! defined( 'ABSPATH' ) ) { 
  22. exit; 
  23.  
  24. do_action( 'woocommerce_before_account_orders', $has_orders ); ?> 
  25.  
  26. <?php if ( $has_orders ) : ?> 
  27.  
  28. <table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table"> 
  29. <thead> 
  30. <tr> 
  31. <?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?> 
  32. <th class="woocommerce-orders-table__header woocommerce-orders-table__header-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th> 
  33. <?php endforeach; ?> 
  34. </tr> 
  35. </thead> 
  36.  
  37. <tbody> 
  38. <?php foreach ( $customer_orders->orders as $customer_order ) : 
  39. $order = wc_get_order( $customer_order ); 
  40. $item_count = $order->get_item_count(); 
  41. ?> 
  42. <tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order"> 
  43. <?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?> 
  44. <td class="woocommerce-orders-table__cell woocommerce-orders-table__cell-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>"> 
  45. <?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?> 
  46. <?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?> 
  47.  
  48. <?php elseif ( 'order-number' === $column_id ) : ?> 
  49. <a href="<?php echo esc_url( $order->get_view_order_url() ); ?>"> 
  50. <?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?> 
  51. </a> 
  52.  
  53. <?php elseif ( 'order-date' === $column_id ) : ?> 
  54. <time datetime="<?php echo esc_attr( $order->get_date_created()->date( 'c' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time> 
  55.  
  56. <?php elseif ( 'order-status' === $column_id ) : ?> 
  57. <?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?> 
  58.  
  59. <?php elseif ( 'order-total' === $column_id ) : ?> 
  60. <?php 
  61. /** translators: 1: formatted order total 2: total order items */ 
  62. printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); 
  63. ?> 
  64.  
  65. <?php elseif ( 'order-actions' === $column_id ) : ?> 
  66. <?php 
  67. $actions = array( 
  68. 'pay' => array( 
  69. 'url' => $order->get_checkout_payment_url(),  
  70. 'name' => __( 'Pay', 'woocommerce' ),  
  71. ),  
  72. 'view' => array( 
  73. 'url' => $order->get_view_order_url(),  
  74. 'name' => __( 'View', 'woocommerce' ),  
  75. ),  
  76. 'cancel' => array( 
  77. 'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),  
  78. 'name' => __( 'Cancel', 'woocommerce' ),  
  79. ),  
  80. ); 
  81.  
  82. if ( ! $order->needs_payment() ) { 
  83. unset( $actions['pay'] ); 
  84.  
  85. if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) { 
  86. unset( $actions['cancel'] ); 
  87.  
  88. if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) { 
  89. foreach ( $actions as $key => $action ) { 
  90. echo '<a href="' . esc_url( $action['url'] ) . '" class="woocommerce-button button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>'; 
  91. ?> 
  92. <?php endif; ?> 
  93. </td> 
  94. <?php endforeach; ?> 
  95. </tr> 
  96. <?php endforeach; ?> 
  97. </tbody> 
  98. </table> 
  99.  
  100. <?php do_action( 'woocommerce_before_account_orders_pagination' ); ?> 
  101.  
  102. <?php if ( 1 < $customer_orders->max_num_pages ) : ?> 
  103. <div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination"> 
  104. <?php if ( 1 !== $current_page ) : ?> 
  105. <a class="woocommerce-button woocommerce-button--previous woocommerce-Button woocommerce-Button--previous button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?></a> 
  106. <?php endif; ?> 
  107.  
  108. <?php if ( intval( $customer_orders->max_num_pages ) !== $current_page ) : ?> 
  109. <a class="woocommerce-button woocommerce-button--next woocommerce-Button woocommerce-Button--next button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?></a> 
  110. <?php endif; ?> 
  111. </div> 
  112. <?php endif; ?> 
  113.  
  114. <?php else : ?> 
  115. <div class="woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info"> 
  116. <a class="woocommerce-Button button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> 
  117. <?php _e( 'Go shop', 'woocommerce' ) ?> 
  118. </a> 
  119. <?php _e( 'No order has been made yet.', 'woocommerce' ); ?> 
  120. </div> 
  121. <?php endif; ?> 
  122.  
  123. <?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?> 
.