From 5e758bb8f9b7acfcafed59df2a515ee8585c6914 Mon Sep 17 00:00:00 2001 From: Nicola Mustone Date: Wed, 8 Apr 2015 14:34:50 +0200 Subject: [PATCH] conditions improvement --- includes/admin/class-wc-admin-post-types.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 223ae5d1f10..b36ec3530d5 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -1797,7 +1797,7 @@ class WC_Admin_Post_Types { $child_product_variations = get_children( 'post_parent=' . $id . '&post_type=product_variation' ); - if ( $child_product_variations ) { + if ( ! empty( $child_product_variations ) ) { foreach ( $child_product_variations as $child ) { wp_delete_post( $child->ID, true ); } @@ -1805,10 +1805,10 @@ class WC_Admin_Post_Types { $child_products = get_children( 'post_parent=' . $id . '&post_type=product' ); - if ( $child_products ) { + if ( ! empty( $child_products ) ) { foreach ( $child_products as $child ) { - $child_post = array(); - $child_post['ID'] = $child->ID; + $child_post = array(); + $child_post['ID'] = $child->ID; $child_post['post_parent'] = 0; wp_update_post( $child_post ); } @@ -1825,8 +1825,10 @@ class WC_Admin_Post_Types { case 'shop_order' : $refunds = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id ) ); - foreach ( $refunds as $refund ) { - wp_delete_post( $refund->ID, true ); + if ( ! is_null( $refunds ) ) { + foreach ( $refunds as $refund ) { + wp_delete_post( $refund->ID, true ); + } } break; }