I want send an API request after adding the product from Woocommerce admin. Actually what I want is that when user adds a new product (A course) to his shop, and API request will create a course with same name as that of product in the LMS.
I have succeeded to hook product creation event but dont know how to get data of the product that I created or added in woocommerce.
Here is my code:
add_action('transition_post_status', 'product_add', 10, 3);
function product_add($new_status, $old_status, $post) {
if(
$old_status != 'publish'
&& $new_status == 'publish'
&& !empty($post->ID)
&& in_array( $post->post_type,
array( 'product')
)
) {
//here I want to get the data of product that is added
}
}
this code is working fine, when I add a product and echo something inside this function it works fine.
Just want to get the Name and Id of the product.
Thanks.