|  | @@ 534-552 (lines=19) @@ | 
                                                            
                                    | 531 |  | 	); | 
                                                            
                                    | 532 |  | } | 
                                                            
                                    | 533 |  |  | 
                                                            
                                    | 534 |  | function wc_update_220_variations() { | 
                                                            
                                    | 535 |  | 	global $wpdb; | 
                                                            
                                    | 536 |  | 	// Update variations which manage stock | 
                                                            
                                    | 537 |  | 	$update_variations = $wpdb->get_results( " | 
                                                            
                                    | 538 |  | 		SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent FROM {$wpdb->posts} as posts | 
                                                            
                                    | 539 |  | 		LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock' | 
                                                            
                                    | 540 |  | 		LEFT OUTER JOIN {$wpdb->postmeta} as postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = '_manage_stock' | 
                                                            
                                    | 541 |  | 		WHERE posts.post_type = 'product_variation' | 
                                                            
                                    | 542 |  | 		AND postmeta.meta_value IS NOT NULL | 
                                                            
                                    | 543 |  | 		AND postmeta.meta_value != '' | 
                                                            
                                    | 544 |  | 		AND postmeta2.meta_value IS NULL | 
                                                            
                                    | 545 |  | 	" ); | 
                                                            
                                    | 546 |  |  | 
                                                            
                                    | 547 |  | 	foreach ( $update_variations as $variation ) { | 
                                                            
                                    | 548 |  | 		$parent_backorders = get_post_meta( $variation->variation_parent, '_backorders', true ); | 
                                                            
                                    | 549 |  | 		add_post_meta( $variation->variation_id, '_manage_stock', 'yes', true ); | 
                                                            
                                    | 550 |  | 		add_post_meta( $variation->variation_id, '_backorders', $parent_backorders ? $parent_backorders : 'no', true ); | 
                                                            
                                    | 551 |  | 	} | 
                                                            
                                    | 552 |  | } | 
                                                            
                                    | 553 |  |  | 
                                                            
                                    | 554 |  | function wc_update_220_attributes() { | 
                                                            
                                    | 555 |  | 	global $wpdb; | 
                                                                                
                                |  | @@ 786-811 (lines=26) @@ | 
                                                            
                                    | 783 |  | 	WC_Install::update_db_version( '2.4.0' ); | 
                                                            
                                    | 784 |  | } | 
                                                            
                                    | 785 |  |  | 
                                                            
                                    | 786 |  | function wc_update_241_variations() { | 
                                                            
                                    | 787 |  | 	global $wpdb; | 
                                                            
                                    | 788 |  |  | 
                                                            
                                    | 789 |  | 	// Select variations that don't have any _stock_status implemented on WooCommerce 2.2 | 
                                                            
                                    | 790 |  | 	$update_variations = $wpdb->get_results( " | 
                                                            
                                    | 791 |  | 		SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent | 
                                                            
                                    | 792 |  | 		FROM {$wpdb->posts} as posts | 
                                                            
                                    | 793 |  | 		LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock_status' | 
                                                            
                                    | 794 |  | 		WHERE posts.post_type = 'product_variation' | 
                                                            
                                    | 795 |  | 		AND postmeta.meta_value IS NULL | 
                                                            
                                    | 796 |  | 	" ); | 
                                                            
                                    | 797 |  |  | 
                                                            
                                    | 798 |  | 	foreach ( $update_variations as $variation ) { | 
                                                            
                                    | 799 |  | 		// Get the parent _stock_status | 
                                                            
                                    | 800 |  | 		$parent_stock_status = get_post_meta( $variation->variation_parent, '_stock_status', true ); | 
                                                            
                                    | 801 |  |  | 
                                                            
                                    | 802 |  | 		// Set the _stock_status | 
                                                            
                                    | 803 |  | 		add_post_meta( $variation->variation_id, '_stock_status', $parent_stock_status ? $parent_stock_status : 'instock', true ); | 
                                                            
                                    | 804 |  |  | 
                                                            
                                    | 805 |  | 		// Delete old product children array | 
                                                            
                                    | 806 |  | 		delete_transient( 'wc_product_children_' . $variation->variation_parent ); | 
                                                            
                                    | 807 |  | 	} | 
                                                            
                                    | 808 |  |  | 
                                                            
                                    | 809 |  | 	// Invalidate old transients such as wc_var_price | 
                                                            
                                    | 810 |  | 	WC_Cache_Helper::get_transient_version( 'product', true ); | 
                                                            
                                    | 811 |  | } | 
                                                            
                                    | 812 |  |  | 
                                                            
                                    | 813 |  | function wc_update_241_db_version() { | 
                                                            
                                    | 814 |  | 	WC_Install::update_db_version( '2.4.1' ); |