class-wc-meta-box-order-notes.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Order Notes
  4. *
  5. * @author WooThemes
  6. * @category Admin
  7. * @package WooCommerce/Admin/Meta Boxes
  8. * @version 2.1.0
  9. */
  10. if ( ! defined( 'ABSPATH' ) ) {
  11. exit; // Exit if accessed directly
  12. }
  13. /**
  14. * WC_Meta_Box_Order_Notes Class.
  15. */
  16. class WC_Meta_Box_Order_Notes {
  17. /**
  18. * Output the metabox.
  19. *
  20. * @param WP_Post $post
  21. */
  22. public static function output( $post ) {
  23. global $post;
  24. $args = array(
  25. 'order_id' => $post->ID,
  26. );
  27. $notes = wc_get_order_notes( $args );
  28. echo '<ul class="order_notes">';
  29. if ( $notes ) {
  30. foreach ( $notes as $note ) {
  31. $note_classes = array( 'note' );
  32. $note_classes[] = $note->customer_note ? 'customer-note' : '';
  33. $note_classes[] = 'system' === $note->added_by ? 'system-note' : '';
  34. $note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
  35. ?>
  36. <li rel="<?php echo absint( $note->id ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
  37. <div class="note_content">
  38. <?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); ?>
  39. </div>
  40. <p class="meta">
  41. <abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
  42. <?php
  43. if ( 'system' !== $note->added_by ) :
  44. /* translators: %s: note author */
  45. printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by );
  46. endif;
  47. ?>
  48. <a href="#" class="delete_note" role="button"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
  49. </p>
  50. </li>
  51. <?php
  52. }
  53. } else {
  54. echo '<li>' . __( 'There are no notes yet.', 'woocommerce' ) . '</li>';
  55. }
  56. echo '</ul>';
  57. ?>
  58. <div class="add_note">
  59. <p>
  60. <label for="add_order_note"><?php _e( 'Add note', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ) ); ?></label>
  61. <textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
  62. </p>
  63. <p>
  64. <label for="order_note_type" class="screen-reader-text"><?php _e( 'Note type', 'woocommerce' ); ?></label>
  65. <select name="order_note_type" id="order_note_type">
  66. <option value=""><?php _e( 'Private note', 'woocommerce' ); ?></option>
  67. <option value="customer"><?php _e( 'Note to customer', 'woocommerce' ); ?></option>
  68. </select>
  69. <button type="button" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></button>
  70. </p>
  71. </div>
  72. <?php
  73. }
  74. }