wc_delete_shop_order_transients( int|WC_Order $order )
Clear all transients cache for order data.
Description Description
Parameters Parameters
- $order
-
(Required) Order instance or ID.
Source Source
File: includes/wc-order-functions.php
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::invalidate_cache_group( 'orders' ); do_action( 'woocommerce_delete_shop_order_transients', $order_id ); }