Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2644-2662 (lines=19) @@
2641
	 * @param  array $variations
2642
	 * @param  array $data
2643
	 */
2644
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2645
		if ( ! isset( $data['value'] ) ) {
2646
			return;
2647
		}
2648
2649
		foreach ( $variations as $variation_id ) {
2650
			// Price fields
2651
			$regular_price = wc_clean( $data['value'] );
2652
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2653
2654
			// Date fields
2655
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2656
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2657
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2658
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2659
2660
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2661
		}
2662
	}
2663
2664
	/**
2665
	 * Bulk action - Set Sale Prices.
@@ 2671-2689 (lines=19) @@
2668
	 * @param  array $variations
2669
	 * @param  array $data
2670
	 */
2671
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2672
		if ( ! isset( $data['value'] ) ) {
2673
			return;
2674
		}
2675
2676
		foreach ( $variations as $variation_id ) {
2677
			// Price fields
2678
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2679
			$sale_price    = wc_clean( $data['value'] );
2680
2681
			// Date fields
2682
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2683
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2684
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2685
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2686
2687
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2688
		}
2689
	}
2690
2691
	/**
2692
	 * Bulk action - Set Stock.