My goal here is to trigger:
('button.save-action').trigger('click');
After adding a product in the admin order creator because I am adding meta via the woocommerce_ajax_add_order_item_meta event but it will not show to the admin until either recalculate or save button is clicked.
here: plugins/woocommerce/assets/js/admin/meta-boxes-order.min.js:333 (need to reformat / unminify to see line number) I found this code:
success: function( response ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
// Update notes.
if ( response.data.notes_html ) {
$( 'ul.order_notes' ).empty();
$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
}
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
} else {
wc_meta_boxes_order_items.unblock();
window.alert( response.data.error );
}
},
complete: function() {
window.wcTracks.recordEvent( 'order_edit_add_products', {
order_id: woocommerce_admin_meta_boxes.post_id,
status: $( '#order_status' ).val()
} );
},
dataType: 'json'
});
Is there a way to listen to either this event:
window.wcTracks.recordEvent( 'order_edit_add_products', {
I have tried code like this but it doesn’t work:
jQuery().on('order_edit_add_products',function(){console.log('event triggered')})
I also saw this reference but I don’t think this way works either: https://nebula.gearside.com/how-to-use-the-javascript-wordpress-hooks-api-without-any-extra-libraries/