WC_Product_Variable_Data_Store_CPT::untrash_variations
Untrash variations.
Метод класса: WC_Product_Variable_Data_Store_CPT{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$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) (обязательный)
- Product ID.
Код WC_Product_Variable_Data_Store_CPT::untrash_variations() WC Product Variable Data Store CPT::untrash variations WC 11.1.0
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 );
}
}
wc_get_container()->get( ProductUtil::class )->delete_product_specific_transients_for_products( array( $product_id ) );
}