Bez popisu

order-details.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. * @package WooCommerce\Templates
  15. * @version 4.6.0
  16. */
  17. defined( 'ABSPATH' ) || exit;
  18. $order = wc_get_order( $order_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
  19. if ( ! $order ) {
  20. return;
  21. }
  22. $order_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
  23. $show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
  24. $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id();
  25. $downloads = $order->get_downloadable_items();
  26. $show_downloads = $order->has_downloadable_item() && $order->is_download_permitted();
  27. if ( $show_downloads ) {
  28. wc_get_template(
  29. 'order/order-downloads.php',
  30. array(
  31. 'downloads' => $downloads,
  32. 'show_title' => true,
  33. )
  34. );
  35. }
  36. ?>
  37. <section class="woocommerce-order-details">
  38. <?php do_action( 'woocommerce_order_details_before_order_table', $order ); ?>
  39. <h2 class="woocommerce-order-details__title"><?php esc_html_e( 'Order details', 'woocommerce' ); ?></h2>
  40. <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
  41. <thead>
  42. <tr>
  43. <th class="woocommerce-table__product-name product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
  44. <th class="woocommerce-table__product-table product-total"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. <?php
  49. do_action( 'woocommerce_order_details_before_order_table_items', $order );
  50. foreach ( $order_items as $item_id => $item ) {
  51. $product = $item->get_product();
  52. wc_get_template(
  53. 'order/order-details-item.php',
  54. array(
  55. 'order' => $order,
  56. 'item_id' => $item_id,
  57. 'item' => $item,
  58. 'show_purchase_note' => $show_purchase_note,
  59. 'purchase_note' => $product ? $product->get_purchase_note() : '',
  60. 'product' => $product,
  61. )
  62. );
  63. }
  64. do_action( 'woocommerce_order_details_after_order_table_items', $order );
  65. ?>
  66. </tbody>
  67. <tfoot>
  68. <?php
  69. foreach ( $order->get_order_item_totals() as $key => $total ) {
  70. ?>
  71. <tr>
  72. <th scope="row"><?php echo esc_html( $total['label'] ); ?></th>
  73. <td><?php echo ( 'payment_method' === $key ) ? esc_html( $total['value'] ) : wp_kses_post( $total['value'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
  74. </tr>
  75. <?php
  76. }
  77. ?>
  78. <?php if ( $order->get_customer_note() ) : ?>
  79. <tr>
  80. <th><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>
  81. <td><?php echo wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) ); ?></td>
  82. </tr>
  83. <?php endif; ?>
  84. </tfoot>
  85. </table>
  86. <?php do_action( 'woocommerce_order_details_after_order_table', $order ); ?>
  87. </section>
  88. <?php
  89. /**
  90. * Action hook fired after the order details.
  91. *
  92. * @since 4.4.0
  93. * @param WC_Order $order Order data.
  94. */
  95. do_action( 'woocommerce_after_order_details', $order );
  96. if ( $show_customer_details ) {
  97. wc_get_template( 'order/order-details-customer.php', array( 'order' => $order ) );
  98. }