WordPress at a glance
function is not described

WC_API_Products::clear_product() protected WC 1.0

Clear product

{} It's a method of the class: WC_API_Products{}

No Hooks.

Return

Null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->clear_product( $product_id );
$product_id(int) (required)
-

Code of WC_API_Products::clear_product() WC 5.0.0

<?php
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();
}