Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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