how can I trigger a function before publish/update a product in woocommerce?

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

Read More
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

Related posts

Leave a Reply

1 comment

  1. 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.