Reload order items on add
This commit is contained in:
parent
2f294a47d8
commit
1596979d75
|
@ -1095,17 +1095,19 @@ jQuery( function ( $ ) {
|
|||
item_to_add: add_item_ids,
|
||||
dataType : 'json',
|
||||
order_id : woocommerce_admin_meta_boxes.post_id,
|
||||
security : woocommerce_admin_meta_boxes.order_item_nonce
|
||||
security : woocommerce_admin_meta_boxes.order_item_nonce,
|
||||
data : $( '#wc-backbone-modal-dialog form' ).serialize()
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
if ( response.success ) {
|
||||
$( 'table.woocommerce_order_items tbody#order_line_items' ).append( response.data.html );
|
||||
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
|
||||
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
|
||||
wc_meta_boxes_order.init_tiptip();
|
||||
wc_meta_boxes_order_items.stupidtable.init();
|
||||
} else {
|
||||
window.alert( response.data.error );
|
||||
}
|
||||
|
||||
wc_meta_boxes_order.init_tiptip();
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ if ( wc_tax_enabled() ) {
|
|||
foreach ( $line_items as $item_id => $item ) {
|
||||
do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
|
||||
|
||||
$class = isset( $new_item_ids ) && is_array( $new_item_ids ) && in_array( $item_id, $new_item_ids ) ? 'new_row' : '';
|
||||
include( 'html-order-item.php' );
|
||||
|
||||
do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
|
||||
|
|
|
@ -770,26 +770,29 @@ class WC_AJAX {
|
|||
$order_id = absint( $_POST['order_id'] );
|
||||
$order = wc_get_order( $order_id );
|
||||
$items_to_add = wp_parse_id_list( is_array( $_POST['item_to_add'] ) ? $_POST['item_to_add'] : array( $_POST['item_to_add'] ) );
|
||||
$new_item_ids = array();
|
||||
|
||||
if ( ! $order ) {
|
||||
throw new Exception( __( 'Invalid order', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
foreach ( $items_to_add as $item_to_add ) {
|
||||
if ( ! in_array( get_post_type( $item_to_add ), array( 'product', 'product_variation' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$item_id = $order->add_product( wc_get_product( $item_to_add ) );
|
||||
$item = apply_filters( 'woocommerce_ajax_order_item', $order->get_item( $item_id ), $item_id );
|
||||
$order_taxes = $order->get_taxes();
|
||||
$class = 'new_row';
|
||||
$item_id = $order->add_product( wc_get_product( $item_to_add ) );
|
||||
$item = apply_filters( 'woocommerce_ajax_order_item', $order->get_item( $item_id ), $item_id );
|
||||
$new_item_ids[] = $item_id;
|
||||
|
||||
do_action( 'woocommerce_ajax_add_order_item_meta', $item_id, $item );
|
||||
include( 'admin/meta-boxes/views/html-order-item.php' );
|
||||
do_action( 'woocommerce_ajax_add_order_item_meta', $item_id, $item, $order );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_ajax_added_order_items', $item_id, $item, $order );
|
||||
|
||||
$data = get_post_meta( $order_id );
|
||||
|
||||
ob_start();
|
||||
include( 'admin/meta-boxes/views/html-order-items.php' );
|
||||
wp_send_json_success( array(
|
||||
'html' => ob_get_clean(),
|
||||
) );
|
||||
|
|
Loading…
Reference in New Issue