woocommerce_product_quick_edit_save hook not fired
-
21-04-2021 - |
Question
I´m trying to add custom fields in the quick edit of woocommerce product. I managed to show fields and populate with jquery but I don´t manage to save data updated.
add_action( 'quick_edit_custom_box', array( $action_class, $quick_edit_method_called ), 99, 3 );
add_action( 'admin_enqueue_scripts', array( $action_class, $quick_edit_script ), 99 );
if( $post_type_slug === 'product' ){
add_action( 'woocommerce_product_quick_edit_save', array( $action_class, $quick_edit_save_post ), 99, 1 );
}else{
add_action( 'save_post', array( $action_class, $quick_edit_save_post ), 99, 2 );
}
quick_edit_custom_box
and admin_enqueue_scripts
work very well but neither woocommerce_product_quick_edit_save
nor save_post
are fired when the administrator click on button 'update' in quick edit.
To test it, I added wp_die('my test must stop here');
inside $action_class::$quick_edit_save_post()
. No success.
Someone has got an idea ?
Solution
I found what was the problem.
the code with actions were wrapped bu this following code :
global pagenow;
if ( $pagenow === "edit.php" && isset( $_GET['post_type'] ) ){}
When there is an ajax call, $pagenow === admin-ajax.php
and $_GET === [ ["_fs_blog_admin"]=> string(4) "true" ]
so that could not be fired.