WC_Product_Variable_Data_Store_CPT::untrash_variations()
Untrash variations.
Method of the class: WC_Product_Variable_Data_Store_CPT{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Product_Variable_Data_Store_CPT = new WC_Product_Variable_Data_Store_CPT(); $WC_Product_Variable_Data_Store_CPT->untrash_variations( $product_id );
- $product_id(int) (required)
- Product ID.
WC_Product_Variable_Data_Store_CPT::untrash_variations() WC Product Variable Data Store CPT::untrash variations code WC 9.4.2
public function untrash_variations( $product_id ) { $variation_ids = wp_parse_id_list( get_posts( array( 'post_parent' => $product_id, 'post_type' => 'product_variation', 'fields' => 'ids', 'post_status' => 'trash', 'numberposts' => -1, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_numberposts ) ) ); if ( ! empty( $variation_ids ) ) { foreach ( $variation_ids as $variation_id ) { wp_untrash_post( $variation_id ); } } delete_transient( 'wc_product_children_' . $product_id ); }