I am trying to get a function that gets some info right before save in the database when user publish or updates a product of woocommerce (in wordpress)
So far, Ive found this
add_action( 'save_post_product', 'method' );
But seems like it is triggered when users enters to create a new product, but I can save it and all without calling this function
Is there any function to do this or any way?
Thanks
Maybe this is your solution:
add_action( 'save_post', 'my_product_update' );
function my_product_update( $post ) {
if($post->post_type == "product"){
$pid=$post->ID;
//your code
}
}
Because I think WooCommerce don`t have default hook for this action.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.