Dashboards widgets

This commit is contained in:
Almira Krdzic
2018-11-29 11:13:15 +01:00
parent 3dbdb657c9
commit 71d615907d
25 changed files with 1139 additions and 426 deletions

View File

@@ -6,6 +6,7 @@ add_action( 'wp_ajax_wiaas_delete_tracking_info', 'wiaas_ajax_delete_tracking_in
add_action( 'wp_ajax_wiaas_save_estimated_date_for_supplier', 'wiaas_ajax_save_estimated_date_for_supplier');
add_action( 'wp_ajax_wiaas_save_confirmed_date_for_supplier', 'wiaas_ajax_save_confirmed_date_for_supplier');
add_action( 'wp_ajax_wiaas_save_estimated_date_for_order', 'wiaas_ajax_save_estimated_date_for_order');
add_action( 'wp_ajax_wiaas_add_order_note', 'wiaas_ajax_add_order_note');
/**
* Adds additional tracking info for supplier in order
@@ -27,6 +28,38 @@ function wiaas_ajax_add_additional_tracking_info_for_supplier_in_order(){
wp_send_json_error($error);
}
/**
* Add order note via ajax.
*/
function wiaas_ajax_add_order_note() {
check_ajax_referer( 'wiaas-add-order-note', 'security' );
if ( ! current_user_can( 'edit_shop_orders' ) ) {
wp_die( -1 );
}
$post_id = absint( $_POST['post_id'] );
$note = wp_kses_post( trim( wp_unslash( $_POST['note'] ) ) );
if ( $post_id > 0 ) {
$order = wc_get_order( $post_id );
$comment_id = $order->add_order_note( $note, true, true );
$note = wc_get_order_note( $comment_id );
?>
<div class="note_content">
<?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); ?>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
<?php
printf( ' ' . __( 'by %s', 'wiaas' ), $note->added_by );
?>
</p>
<?php
}
wp_die();
}
function wiaas_ajax_save_tracking_info(){
check_ajax_referer('wiaas_save_tracking_info');
$error = new WP_Error('-1', 'Failed to save tracking info');