Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2665-2683 (lines=19) @@
2662
	 * @param  array $variations
2663
	 * @param  array $data
2664
	 */
2665
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2666
		if ( ! isset( $data['value'] ) ) {
2667
			return;
2668
		}
2669
2670
		foreach ( $variations as $variation_id ) {
2671
			// Price fields
2672
			$regular_price = wc_clean( $data['value'] );
2673
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2674
2675
			// Date fields
2676
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2677
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2678
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2679
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2680
2681
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2682
		}
2683
	}
2684
2685
	/**
2686
	 * Bulk action - Set Sale Prices.
@@ 2691-2709 (lines=19) @@
2688
	 * @param  array $variations
2689
	 * @param  array $data
2690
	 */
2691
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2692
		if ( ! isset( $data['value'] ) ) {
2693
			return;
2694
		}
2695
2696
		foreach ( $variations as $variation_id ) {
2697
			// Price fields
2698
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2699
			$sale_price    = wc_clean( $data['value'] );
2700
2701
			// Date fields
2702
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2703
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2704
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2705
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2706
2707
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2708
		}
2709
	}
2710
2711
	/**
2712
	 * Bulk action - Set Stock.