WordPress at a glance
function is not described

WC_REST_Products_V1_Controller::delete_post() protected WC 1.0

Delete post.

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

No Hooks.

Return

Null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->delete_post( $id );
$id(int|WP_Post) (required)
Post ID or WP_Post instance.

Code of WC_REST_Products_V1_Controller::delete_post() WC 5.0.0

<?php
protected function delete_post( $id ) {
	if ( ! empty( $id->ID ) ) {
		$id = $id->ID;
	} elseif ( ! is_numeric( $id ) || 0 >= $id ) {
		return;
	}

	// Delete product attachments.
	$attachments = get_posts( array(
		'post_parent' => $id,
		'post_status' => 'any',
		'post_type'   => 'attachment',
	) );

	foreach ( (array) $attachments as $attachment ) {
		wp_delete_attachment( $attachment->ID, true );
	}

	// Delete product.
	$product = wc_get_product( $id );
	$product->delete( true );
}