Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2618-2636 (lines=19) @@
2615
	 * @param  array $variations
2616
	 * @param  array $data
2617
	 */
2618
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2619
		if ( ! isset( $data['value'] ) ) {
2620
			return;
2621
		}
2622
2623
		foreach ( $variations as $variation_id ) {
2624
			// Price fields
2625
			$regular_price = wc_clean( $data['value'] );
2626
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2627
2628
			// Date fields
2629
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2630
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2631
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2632
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2633
2634
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2635
		}
2636
	}
2637
2638
	/**
2639
	 * Bulk action - Set Sale Prices.
@@ 2645-2663 (lines=19) @@
2642
	 * @param  array $variations
2643
	 * @param  array $data
2644
	 */
2645
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2646
		if ( ! isset( $data['value'] ) ) {
2647
			return;
2648
		}
2649
2650
		foreach ( $variations as $variation_id ) {
2651
			// Price fields
2652
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2653
			$sale_price    = wc_clean( $data['value'] );
2654
2655
			// Date fields
2656
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2657
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2658
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2659
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2660
2661
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2662
		}
2663
	}
2664
2665
	/**
2666
	 * Bulk action - Set Stock.