order-details.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Order details
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/order/order-details.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 3.3.0
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit;
  20. }
  21. if ( ! $order = wc_get_order( $order_id ) ) {
  22. return;
  23. }
  24. $order_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
  25. $show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
  26. $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id();
  27. $downloads = $order->get_downloadable_items();
  28. $show_downloads = $order->has_downloadable_item() && $order->is_download_permitted();
  29. if ( $show_downloads ) {
  30. wc_get_template( 'order/order-downloads.php', array( 'downloads' => $downloads, 'show_title' => true ) );
  31. }
  32. ?>
  33. <section class="woocommerce-order-details">
  34. <?php do_action( 'woocommerce_order_details_before_order_table', $order ); ?>
  35. <h2 class="woocommerce-order-details__title"><?php _e( 'Order details', 'woocommerce' ); ?></h2>
  36. <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
  37. <thead>
  38. <tr>
  39. <th class="woocommerce-table__product-name product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
  40. <th class="woocommerce-table__product-table product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. <?php
  45. do_action( 'woocommerce_order_details_before_order_table_items', $order );
  46. foreach ( $order_items as $item_id => $item ) {
  47. $product = $item->get_product();
  48. wc_get_template( 'order/order-details-item.php', array(
  49. 'order' => $order,
  50. 'item_id' => $item_id,
  51. 'item' => $item,
  52. 'show_purchase_note' => $show_purchase_note,
  53. 'purchase_note' => $product ? $product->get_purchase_note() : '',
  54. 'product' => $product,
  55. ) );
  56. }
  57. do_action( 'woocommerce_order_details_after_order_table_items', $order );
  58. ?>
  59. </tbody>
  60. <tfoot>
  61. <?php
  62. foreach ( $order->get_order_item_totals() as $key => $total ) {
  63. ?>
  64. <tr>
  65. <th scope="row"><?php echo $total['label']; ?></th>
  66. <td><?php echo $total['value']; ?></td>
  67. </tr>
  68. <?php
  69. }
  70. ?>
  71. <?php if ( $order->get_customer_note() ) : ?>
  72. <tr>
  73. <th><?php _e( 'Note:', 'woocommerce' ); ?></th>
  74. <td><?php echo wptexturize( $order->get_customer_note() ); ?></td>
  75. </tr>
  76. <?php endif; ?>
  77. </tfoot>
  78. </table>
  79. <?php do_action( 'woocommerce_order_details_after_order_table', $order ); ?>
  80. </section>
  81. <?php
  82. if ( $show_customer_details ) {
  83. wc_get_template( 'order/order-details-customer.php', array( 'order' => $order ) );
  84. }