Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2696-2714 (lines=19) @@
2693
	 * @param  array $variations
2694
	 * @param  array $data
2695
	 */
2696
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2697
		if ( ! isset( $data['value'] ) ) {
2698
			return;
2699
		}
2700
2701
		foreach ( $variations as $variation_id ) {
2702
			// Price fields
2703
			$regular_price = wc_clean( $data['value'] );
2704
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2705
2706
			// Date fields
2707
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2708
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2709
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2710
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2711
2712
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2713
		}
2714
	}
2715
2716
	/**
2717
	 * Bulk action - Set Sale Prices.
@@ 2722-2740 (lines=19) @@
2719
	 * @param  array $variations
2720
	 * @param  array $data
2721
	 */
2722
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2723
		if ( ! isset( $data['value'] ) ) {
2724
			return;
2725
		}
2726
2727
		foreach ( $variations as $variation_id ) {
2728
			// Price fields
2729
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2730
			$sale_price    = wc_clean( $data['value'] );
2731
2732
			// Date fields
2733
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2734
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2735
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2736
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2737
2738
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2739
		}
2740
	}
2741
2742
	/**
2743
	 * Bulk action - Set Stock.