wc_delete_shop_order_transients functions and trigger when order status updates. Closes #4875
This commit is contained in:
parent
4685753e27
commit
967aba149c
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -1307,7 +1307,7 @@ class WC_Order {
|
|||
|
||||
}
|
||||
|
||||
delete_transient( 'woocommerce_processing_order_count' );
|
||||
wc_delete_shop_order_transients( $this->id );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue