Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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