WC_AJAX::add_order_note PHP Méthode

add_order_note() public static méthode

Add order note via ajax.
public static add_order_note ( )
    public static function add_order_note()
    {
        check_ajax_referer('add-order-note', 'security');
        if (!current_user_can('edit_shop_orders')) {
            die(-1);
        }
        $post_id = absint($_POST['post_id']);
        $note = wp_kses_post(trim(stripslashes($_POST['note'])));
        $note_type = $_POST['note_type'];
        $is_customer_note = 'customer' === $note_type ? 1 : 0;
        if ($post_id > 0) {
            $order = wc_get_order($post_id);
            $comment_id = $order->add_order_note($note, $is_customer_note, true);
            echo '<li rel="' . esc_attr($comment_id) . '" class="note ';
            if ($is_customer_note) {
                echo 'customer-note';
            }
            echo '"><div class="note_content">';
            echo wpautop(wptexturize($note));
            echo '</div><p class="meta"><a href="#" class="delete_note">' . __('Delete note', 'woocommerce') . '</a></p>';
            echo '</li>';
        }
        die;
    }
WC_AJAX