Created
March 15, 2021 13:14
-
-
Save iyut/35b97134298f9c43d293023cad323202 to your computer and use it in GitHub Desktop.
Hook after product is created or updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'save_post', 'product_created_or_updated', 10, 3); | |
function product_created_or_updated($post_id, $post, $update){ | |
if ($post->post_status != 'publish' || $post->post_type != 'product') { | |
return; | |
} | |
if ( !$product = wc_get_product( $post_id ) ) { | |
return; | |
} | |
// Make something with $product | |
// You can also check $update | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment