Guest User

Untitled

a guest
Mar 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. // Add customer order notes for order list with v3.3
  2. add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 );
  3. function custom_shop_order_column( $columns )
  4. {
  5. $ordered_columns = array();
  6.  
  7. foreach( $columns as $key => $column ){
  8. $ordered_columns[$key] = $column;
  9. if( 'order_date' == $key ){
  10. $ordered_columns['order_notes'] = '訂單備註';
  11. }
  12. }
  13.  
  14. return $ordered_columns;
  15. }
  16.  
  17. add_action( 'manage_shop_order_posts_custom_column' , 'custom_shop_order_list_column_content', 10, 1 );
  18. function custom_shop_order_list_column_content( $column )
  19. {
  20. global $post, $the_order;
  21.  
  22. $customer_note = $post->post_excerpt;
  23.  
  24. if ( $column == 'order_notes' ) {
  25.  
  26. if ( $the_order->get_customer_note() ) {
  27. echo '<span class="note-on customer tips" data-tip="' . wc_sanitize_tooltip( $the_order->get_customer_note() ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
  28. }
  29.  
  30. if ( $post->comment_count ) {
  31.  
  32. $latest_notes = wc_get_order_notes( array(
  33. 'order_id' => $post->ID,
  34. 'limit' => 1,
  35. 'orderby' => 'date_created_gmt',
  36. ) );
  37.  
  38. $latest_note = current( $latest_notes );
  39.  
  40. if ( isset( $latest_note->content ) && 1 == $post->comment_count ) {
  41. echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
  42. } elseif ( isset( $latest_note->content ) ) {
  43. // translators: %d: notes count
  44. echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content . '<br/><small style="display:block">' . sprintf( _n( 'Plus %d other note', 'Plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
  45. } else {
  46. // translators: %d: notes count
  47. echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( sprintf( _n( '%d note', '%d notes', $post->comment_count, 'woocommerce' ), $post->comment_count ) ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
  48. }
  49. }
  50. }
  51. }
  52.  
  53. // Set Here the WooCommerce icon for your action button
  54. add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
  55. function add_custom_order_status_actions_button_css() {
  56. echo '<style>
  57. td.order_notes > .note-on { display: inline-block !important;}
  58. span.note-on.customer { margin-right: 4px !important;}
  59. span.note-on.customer::after { font-family: woocommerce !important; content: "\e026" !important;}
  60. </style>';
  61. }
Add Comment
Please, Sign In to add comment