From 5f573b87779eb5559c95c957c1c1e9b5110eea2a Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 28 Mar 2017 14:01:02 +0100 Subject: [PATCH] Clear parent transient on variation creation --- .../data-stores/class-wc-product-variation-data-store-cpt.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/data-stores/class-wc-product-variation-data-store-cpt.php b/includes/data-stores/class-wc-product-variation-data-store-cpt.php index 09c1b25be12..a8645e10e6b 100644 --- a/includes/data-stores/class-wc-product-variation-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-variation-data-store-cpt.php @@ -102,7 +102,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl 'post_author' => get_current_user_id(), 'post_title' => $this->generate_product_title( $product ), 'post_content' => '', - 'post_parent' => $product->get_parent_id(), + 'post_parent' => $product->get_parent_id( 'edit' ), 'comment_status' => 'closed', 'ping_status' => 'closed', 'menu_order' => $product->get_menu_order(), @@ -113,6 +113,8 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl if ( $id && ! is_wp_error( $id ) ) { $product->set_id( $id ); + delete_transient( 'wc_product_children_' . $product->get_parent_id( 'edit' ) ); + $this->update_post_meta( $product, true ); $this->update_terms( $product, true ); $this->update_attributes( $product, true );