Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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