/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php

  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.  
  11. if ( ! defined( 'ABSPATH' ) ) { 
  12. exit; // Exit if accessed directly 
  13.  
  14. /** 
  15. * WC_Meta_Box_Order_Notes Class. 
  16. */ 
  17. class WC_Meta_Box_Order_Notes { 
  18.  
  19. /** 
  20. * Output the metabox. 
  21. * 
  22. * @param WP_Post $post 
  23. */ 
  24. public static function output( $post ) { 
  25. global $post; 
  26.  
  27. $args = array( 
  28. 'post_id' => $post->ID,  
  29. 'orderby' => 'comment_ID',  
  30. 'order' => 'DESC',  
  31. 'approve' => 'approve',  
  32. 'type' => 'order_note',  
  33. ); 
  34.  
  35. remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); 
  36.  
  37. $notes = get_comments( $args ); 
  38.  
  39. add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); 
  40.  
  41. echo '<ul class="order_notes">'; 
  42.  
  43. if ( $notes ) { 
  44.  
  45. foreach ( $notes as $note ) { 
  46.  
  47. $note_classes = array( 'note' ); 
  48. $note_classes[] = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? 'customer-note' : ''; 
  49. $note_classes[] = ( __( 'WooCommerce', 'woocommerce' ) === $note->comment_author ) ? 'system-note' : ''; 
  50. $note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note ); 
  51. ?> 
  52. <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>"> 
  53. <div class="note_content"> 
  54. <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> 
  55. </div> 
  56. <p class="meta"> 
  57. <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), date_i18n( wc_date_format(), strtotime( $note->comment_date ) ), date_i18n( wc_time_format(), strtotime( $note->comment_date ) ) ); ?></abbr> 
  58. <?php 
  59. if ( __( 'WooCommerce', 'woocommerce' ) !== $note->comment_author ) : 
  60. /** translators: %s: note author */ 
  61. printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author ); 
  62. endif; 
  63. ?> 
  64. <a href="#" class="delete_note" role="button"><?php _e( 'Delete note', 'woocommerce' ); ?></a> 
  65. </p> 
  66. </li> 
  67. <?php 
  68. } else { 
  69. echo '<li>' . __( 'There are no notes yet.', 'woocommerce' ) . '</li>'; 
  70.  
  71. echo '</ul>'; 
  72. ?> 
  73. <div class="add_note"> 
  74. <p> 
  75. <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> 
  76. <textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea> 
  77. </p> 
  78. <p> 
  79. <label for="order_note_type" class="screen-reader-text"><?php _e( 'Note type', 'woocommerce' ); ?></label> 
  80. <select name="order_note_type" id="order_note_type"> 
  81. <option value=""><?php _e( 'Private note', 'woocommerce' ); ?></option> 
  82. <option value="customer"><?php _e( 'Note to customer', 'woocommerce' ); ?></option> 
  83. </select> 
  84. <button type="button" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></button> 
  85. </p> 
  86. </div> 
  87. <?php 
.