wc_delete_shop_order_transients functions and trigger when order status updates. Closes #4875

This commit is contained in:
Mike Jolley 2014-02-26 15:43:19 +00:00 committed by Coen Jacobs
parent 4685753e27
commit 967aba149c
3 changed files with 26 additions and 4 deletions

View File

@ -395,8 +395,6 @@ class WC_Meta_Box_Order_Data {
// Order status
$order->update_status( $_POST['order_status'] );
delete_transient( 'woocommerce_processing_order_count' );
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_wc_report_%') OR `option_name` LIKE ('_transient_timeout_wc_report_%')" );
wc_delete_shop_order_transients( $post_id );
}
}

View File

@ -1307,7 +1307,7 @@ class WC_Order {
}
delete_transient( 'woocommerce_processing_order_count' );
wc_delete_shop_order_transients( $this->id );
}

View File

@ -325,3 +325,27 @@ function wc_processing_order_count() {
return $order_count;
}
/**
* 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'
);
foreach( $transients_to_clear as $transient ) {
delete_transient( $transient );
}
// Clear transients for which we don't have the name
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_wc_report_%') OR `option_name` LIKE ('_transient_timeout_wc_report_%')" );
do_action( 'woocommerce_delete_shop_order_transients', $post_id );
}