Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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