1
votes

I've looked through Woocommerce API Docs to see if there's any way to manipulate the product after it gets inserted in the admin backend of Wordpress but couldn't find any. Maybe I missed it?

I need to pick product data and send it to an external API, and obviously, handle it on update and delete...

Is there any way/hook I can use?

2

2 Answers

3
votes

This goes more into what I want. Taken from this answer in WP forum. Thanks to the author

add_action('transition_post_status', 'wpse_110037_new_posts', 10, 3);
 function wpse_110037_new_posts($new_status, $old_status, $post) {
 if( 
        $old_status != 'publish' 
        && $new_status == 'publish' 
        && !empty($post->ID) 
        && in_array( $post->post_type, 
            array( 'product') 
            )
        ) {
          //add some cde here
     }

  }
0
votes
If You add a new product in woocommerce then send product_id

add_action('draft_to_publish','my_product_update');

function my_product_update( $post ) {

if($post->post_type == "product"){

$pid=$post->ID;

//your code
}

}