wc_delete_product_transients()
Clear transient cache for product data.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wc_delete_product_transients( $post_id );
- $post_id(int)
- -
По умолчанию: 0) The product ID
Код wc_delete_product_transients() wc delete product transients WC 9.4.2
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. $post_transient_names = array( 'wc_product_children_', 'wc_var_prices_', 'wc_related_', 'wc_child_has_weight_', 'wc_child_has_dimensions_', ); foreach ( $post_transient_names as $transient ) { delete_transient( $transient . $post_id ); } } // Increments the transient version to invalidate cache. WC_Cache_Helper::get_transient_version( 'product', true ); do_action( 'woocommerce_delete_product_transients', $post_id ); }