woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-not...

92 lines
2.9 KiB
PHP
Raw Normal View History

2013-08-06 10:41:20 +00:00
<?php
/**
2015-11-03 13:53:50 +00:00
* Order Notes
2013-08-06 10:41:20 +00:00
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Meta Boxes
2013-08-06 10:41:20 +00:00
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
2013-08-06 10:41:20 +00:00
/**
* WC_Meta_Box_Order_Notes Class.
2013-08-06 10:41:20 +00:00
*/
class WC_Meta_Box_Order_Notes {
/**
* Output the metabox.
*
* @param WP_Post $post
2013-08-06 10:41:20 +00:00
*/
public static function output( $post ) {
global $post;
2013-08-06 10:41:20 +00:00
$args = array(
'post_id' => $post->ID,
'orderby' => 'comment_ID',
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note',
2013-08-06 10:41:20 +00:00
);
remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
2013-08-06 10:41:20 +00:00
$notes = get_comments( $args );
add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
2013-08-06 10:41:20 +00:00
echo '<ul class="order_notes">';
if ( $notes ) {
foreach ( $notes as $note ) {
$note_classes = array( 'note' );
$note_classes[] = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? 'customer-note' : '';
2016-09-09 00:14:28 +00:00
$note_classes[] = ( __( 'WooCommerce', 'woocommerce' ) === $note->comment_author ) ? 'system-note' : '';
$note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
2013-08-06 10:41:20 +00:00
?>
<li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
2013-08-06 10:41:20 +00:00
<div class="note_content">
<?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
</div>
<p class="meta">
2014-10-22 15:31:12 +00:00
<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>
2016-10-29 10:16:03 +00:00
<?php
if ( __( 'WooCommerce', 'woocommerce' ) !== $note->comment_author ) :
/* translators: %s: note author */
printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author );
endif;
?>
2013-08-06 10:41:20 +00:00
<a href="#" class="delete_note"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
</p>
</li>
<?php
}
} else {
echo '<li>' . __( 'There are no notes yet.', 'woocommerce' ) . '</li>';
2013-08-06 10:41:20 +00:00
}
echo '</ul>';
?>
<div class="add_note">
<h4><?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' ) ); ?></h4>
2013-08-06 10:41:20 +00:00
<p>
<textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
</p>
<p>
<select name="order_note_type" id="order_note_type">
<option value=""><?php _e( 'Private note', 'woocommerce' ); ?></option>
<option value="customer"><?php _e( 'Note to customer', 'woocommerce' ); ?></option>
2013-08-06 10:41:20 +00:00
</select>
<a href="#" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></a>
</p>
</div>
<?php
}
}