WC_Post_Data::transition_post_status
When a post status changes.
Method of the class: WC_Post_Data{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$result = WC_Post_Data::transition_post_status( $new_status, $old_status, $post );
- $new_status(string) (required)
- New status.
- $old_status(string) (required)
- Old status.
- $post(WP_Post) (required)
- Post data.
WC_Post_Data::transition_post_status() WC Post Data::transition post status code WC 10.9.4
public static function transition_post_status( $new_status, $old_status, $post ) {
if ( ( ProductStatus::PUBLISH === $new_status || ProductStatus::PUBLISH === $old_status ) && in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
self::delete_product_query_transients();
}
if ( ProductStatus::PUBLISH === $new_status && ProductStatus::PUBLISH !== $old_status && in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
/**
* Fires when a product or product variation transitions to published status.
*
* @since 10.8.0
* @param int $product_id The product or variation ID.
*/
do_action( 'woocommerce_product_published', $post->ID );
}
}