예제 #1
0
/**
 * Clear all transients cache for order data.
 *
 * @param int $post_id (default: 0)
 */
function wc_delete_shop_order_transients($post_id = 0)
{
    $post_id = absint($post_id);
    $transients_to_clear = array();
    // Clear report transients
    $reports = WC_Admin_Reports::get_reports();
    foreach ($reports as $report_group) {
        foreach ($report_group['reports'] as $report_key => $report) {
            $transients_to_clear[] = 'wc_report_' . $report_key;
        }
    }
    // clear API report transient
    $transients_to_clear[] = 'wc_admin_report';
    // Clear transients where we have names
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    // Increments the transient version to invalidate cache
    WC_Cache_Helper::get_transient_version('orders', true);
    do_action('woocommerce_delete_shop_order_transients', $post_id);
}
예제 #2
0
/**
 * Clear all transients cache for order data.
 *
 * @param int $post_id (default: 0)
 */
function wc_delete_shop_order_transients($post_id = 0)
{
    $post_id = absint($post_id);
    $transients_to_clear = array();
    // Clear report transients
    $reports = WC_Admin_Reports::get_reports();
    foreach ($reports as $report_group) {
        foreach ($report_group['reports'] as $report_key => $report) {
            $transients_to_clear[] = 'wc_report_' . $report_key;
        }
    }
    // clear API report transient
    $transients_to_clear[] = 'wc_admin_report';
    // Clear transients where we have names
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    do_action('woocommerce_delete_shop_order_transients', $post_id);
}
 /**
  * Init the reports page.
  */
 public function reports_page()
 {
     WC_Admin_Reports::output();
 }
 /**
  * Init the reports page
  */
 public function reports_page()
 {
     include_once 'class-wc-admin-reports.php';
     WC_Admin_Reports::output();
 }
/**
 * Clear all transients cache for order data.
 *
 * @param int|WC_Order $order
 */
function wc_delete_shop_order_transients($order = 0)
{
    if (is_numeric($order)) {
        $order = wc_get_order($order);
    }
    $reports = WC_Admin_Reports::get_reports();
    $transients_to_clear = array('wc_admin_report');
    foreach ($reports as $report_group) {
        foreach ($report_group['reports'] as $report_key => $report) {
            $transients_to_clear[] = 'wc_report_' . $report_key;
        }
    }
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    // Clear money spent for user associated with order
    if (is_a($order, 'WC_Order')) {
        $order_id = $order->get_id();
        delete_user_meta($order->get_customer_id(), '_money_spent');
        delete_user_meta($order->get_customer_id(), '_order_count');
    } else {
        $order_id = 0;
    }
    // Increments the transient version to invalidate cache
    WC_Cache_Helper::get_transient_version('orders', true);
    // Do the same for regular cache
    WC_Cache_Helper::incr_cache_prefix('orders');
    do_action('woocommerce_delete_shop_order_transients', $order_id);
}
예제 #6
0
/**
 * Clear all transients cache for order data.
 *
 * @param int $post_id (default: 0)
 */
function wc_delete_shop_order_transients($post_id = 0)
{
    $post_id = absint($post_id);
    $transients_to_clear = array();
    // Clear report transients
    $reports = WC_Admin_Reports::get_reports();
    foreach ($reports as $report_group) {
        foreach ($report_group['reports'] as $report_key => $report) {
            $transients_to_clear[] = 'wc_report_' . $report_key;
        }
    }
    // clear API report transient
    $transients_to_clear[] = 'wc_admin_report';
    // Clear transients where we have names
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    // Clear money spent for user associated with order
    if ($post_id && ($user_id = get_post_meta($post_id, '_customer_user', true))) {
        delete_user_meta($user_id, '_money_spent');
        delete_user_meta($user_id, '_order_count');
    }
    // Increments the transient version to invalidate cache
    WC_Cache_Helper::get_transient_version('orders', true);
    // Do the same for regular cache
    WC_Cache_Helper::incr_cache_prefix('orders');
    do_action('woocommerce_delete_shop_order_transients', $post_id);
}
예제 #7
0
/**
 * Clear all transients cache for order data.
 *
 * @param int $post_id (default: 0)
 */
function wc_delete_shop_order_transients($post_id = 0)
{
    global $wpdb;
    $post_id = absint($post_id);
    // Clear core transients
    $transients_to_clear = array('woocommerce_processing_order_count');
    // Clear report transients
    $reports = WC_Admin_Reports::get_reports();
    foreach ($reports as $report_group) {
        foreach ($report_group['reports'] as $report_key => $report) {
            $transients_to_clear[] = 'wc_report_' . $report_key;
        }
    }
    // Clear transients where we have names
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    do_action('woocommerce_delete_shop_order_transients', $post_id);
}