Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2683-2701 (lines=19) @@
2680
	 * @param  array $variations
2681
	 * @param  array $data
2682
	 */
2683
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2684
		if ( ! isset( $data['value'] ) ) {
2685
			return;
2686
		}
2687
2688
		foreach ( $variations as $variation_id ) {
2689
			// Price fields
2690
			$regular_price = wc_clean( $data['value'] );
2691
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2692
2693
			// Date fields
2694
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2695
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2696
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2697
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2698
2699
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2700
		}
2701
	}
2702
2703
	/**
2704
	 * Bulk action - Set Sale Prices.
@@ 2709-2727 (lines=19) @@
2706
	 * @param  array $variations
2707
	 * @param  array $data
2708
	 */
2709
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2710
		if ( ! isset( $data['value'] ) ) {
2711
			return;
2712
		}
2713
2714
		foreach ( $variations as $variation_id ) {
2715
			// Price fields
2716
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2717
			$sale_price    = wc_clean( $data['value'] );
2718
2719
			// Date fields
2720
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2721
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2722
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2723
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2724
2725
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2726
		}
2727
	}
2728
2729
	/**
2730
	 * Bulk action - Set Stock.