Ensure child_ids (transient) is cleared on delete. Closes #1786.

This commit is contained in:
Mike Jolley 2012-11-21 18:26:42 +00:00
parent 75ca794bba
commit 841624a0b2
2 changed files with 5 additions and 3 deletions

View File

@ -83,7 +83,8 @@ function woocommerce_ms_protect_download_rewite_rules( $rewrite ) {
* @return void * @return void
*/ */
function woocommerce_delete_post( $id ) { function woocommerce_delete_post( $id ) {
global $woocommerce;
if ( ! current_user_can( 'delete_posts' ) ) return; if ( ! current_user_can( 'delete_posts' ) ) return;
if ( $id > 0 ) : if ( $id > 0 ) :
@ -103,7 +104,8 @@ function woocommerce_delete_post( $id ) {
endif; endif;
endif; endif;
$woocommerce->clear_product_transients();
delete_transient( 'woocommerce_processing_order_count' ); delete_transient( 'woocommerce_processing_order_count' );
} }

View File

@ -393,7 +393,7 @@ class WC_Product {
function exists() { function exists() {
global $wpdb; global $wpdb;
return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d LIMIT 1;", $this->id ) ) > 0 ? true : false; return ! empty( $this->post ) || $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d LIMIT 1;", $this->id ) ) > 0 ? true : false;
} }