wc_delete_product_transients()WC 1.0

Clear transient cache for product data.

Hooks from the function

Returns

null. Nothing (null).

Usage

wc_delete_product_transients( $post_id );
$post_id(int)
.
Default: 0) The product ID

wc_delete_product_transients() code WC 10.4.3

function wc_delete_product_transients( $post_id = 0 ) {
	// Transient data to clear with a fixed name which may be stale after product updates.
	$transients_to_clear = array(
		'wc_products_onsale',
		'wc_featured_products',
		'wc_outofstock_count',
		'wc_low_stock_count',
	);

	foreach ( $transients_to_clear as $transient ) {
		delete_transient( $transient );
	}

	if ( $post_id > 0 ) {
		// Transient names that include an ID - since they are dynamic they cannot be cleaned in bulk without the ID.
		wc_get_container()->get( ProductUtil::class )->delete_product_specific_transients( $post_id );
	}

	// Kept for compatibility, WooCommerce core doesn't use product transient versions anymore.
	WC_Cache_Helper::get_transient_version( 'product', true );

	do_action( 'woocommerce_delete_product_transients', $post_id );
}