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' ) ) exit; // Exit if accessed directly
12 
13 /**
14  * WC_Meta_Box_Order_Notes
15  */
16 class WC_Meta_Box_Order_Notes {
17 
18     /**
19      * Output the metabox
20      */
21     public static function output( $post ) {
22         global $woocommerce, $post;
23 
24         $args = array(
25             'post_id'   => $post->ID,
26             'approve'   => 'approve',
27             'type'      => 'order_note'
28         );
29 
30         remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
31 
32         $notes = get_comments( $args );
33 
34         add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
35 
36         echo '<ul class="order_notes">';
37 
38         if ( $notes ) {
39             foreach( $notes as $note ) {
40                 $note_classes = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? array( 'customer-note', 'note' ) : array( 'note' );
41 
42                 ?>
43                 <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo implode( ' ', $note_classes ); ?>">
44                     <div class="note_content">
45                         <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
46                     </div>
47                     <p class="meta">
48                         <abbr class="exact-date" title="<?php echo $note->comment_date_gmt; ?> GMT"><?php printf( __( 'added %s ago', 'woocommerce' ), human_time_diff( strtotime( $note->comment_date_gmt ), current_time( 'timestamp', 1 ) ) ); ?></abbr>
49                         <?php if ( $note->comment_author !== __( 'WooCommerce', 'woocommerce' ) ) printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author ); ?>
50                         <a href="#" class="delete_note"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
51                     </p>
52                 </li>
53                 <?php
54             }
55         } else {
56             echo '<li>' . __( 'There are no notes for this order yet.', 'woocommerce' ) . '</li>';
57         }
58 
59         echo '</ul>';
60         ?>
61         <div class="add_note">
62             <h4><?php _e( 'Add note', 'woocommerce' ); ?> <img class="help_tip" data-tip='<?php esc_attr_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ); ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></h4>
63             <p>
64                 <textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
65             </p>
66             <p>
67                 <select name="order_note_type" id="order_note_type">
68                     <option value="customer"><?php _e( 'Customer note', 'woocommerce' ); ?></option>
69                     <option value=""><?php _e( 'Private note', 'woocommerce' ); ?></option>
70                 </select>
71                 <a href="#" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></a>
72             </p>
73         </div>
74         <?php
75     }
76 }
WooCommerce API documentation generated by ApiGen 2.8.0