WC_API_Products::clear_product()
Clear product
Метод класса: WC_API_Products{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->clear_product( $product_id );
- $product_id(int) (обязательный)
- -
Код WC_API_Products::clear_product() WC API Products::clear product WC 8.7.0
protected function clear_product( $product_id ) { if ( ! is_numeric( $product_id ) || 0 >= $product_id ) { return; } // Delete product attachments $attachments = get_children( array( 'post_parent' => $product_id, 'post_status' => 'any', 'post_type' => 'attachment', ) ); foreach ( (array) $attachments as $attachment ) { wp_delete_attachment( $attachment->ID, true ); } // Delete product $product = wc_get_product( $product_id ); $product->delete( true ); }