Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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