تابع ووکامرسی wc_delete_product_transients حذف تمامی اطلاعات موقتی محصول
تابع ووکامرسی wc_delete_product_transients – حذف تمامی اطلاعات موقتی محصول مثل cache
Syntax – سینتکس
wc_delete_product_transients( (int) $post_id = 0 );
Parameters – پارامتر ها (1)
- 1- $post_id (int)
Usage – نحوه استفاده
if ( !function_exists( 'wc_delete_product_transients' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php'; } // The post id. $post_id = -1; // NOTICE! Understand what this does before running. $result = wc_delete_product_transients($post_id);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_delete_product_transients( $post_id = 0 ) { // Core transients $transients_to_clear = array( 'wc_products_onsale', 'wc_featured_products', 'wc_outofstock_count', 'wc_low_stock_count', ); // Transient names that include an ID $post_transient_names = array( 'wc_product_children_', 'wc_var_prices_', 'wc_related_', 'wc_child_has_weight_', 'wc_child_has_dimensions_', ); if ( $post_id > 0 ) { foreach ( $post_transient_names as $transient ) { $transients_to_clear[] = $transient . $post_id; } // Does this product have a parent? $product = wc_get_product( $post_id ); if ( $product && $product->get_parent_id() > 0 ) { wc_delete_product_transients( $product->get_parent_id() ); } } // Delete transients foreach ( $transients_to_clear as $transient ) { delete_transient( $transient ); } // Increments the transient version to invalidate cache WC_Cache_Helper::get_transient_version( 'product', true ); do_action( 'woocommerce_delete_product_transients', $post_id ); }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر