Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2484-2502 (lines=19) @@
2481
	 * @param  array $variations
2482
	 * @param  array $data
2483
	 */
2484
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2485
		if ( ! isset( $data['value'] ) ) {
2486
			return;
2487
		}
2488
2489
		foreach ( $variations as $variation_id ) {
2490
			// Price fields
2491
			$regular_price = wc_clean( $data['value'] );
2492
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2493
2494
			// Date fields
2495
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2496
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2497
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2498
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2499
2500
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2501
		}
2502
	}
2503
2504
	/**
2505
	 * Bulk action - Set Sale Prices.
@@ 2511-2529 (lines=19) @@
2508
	 * @param  array $variations
2509
	 * @param  array $data
2510
	 */
2511
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2512
		if ( ! isset( $data['value'] ) ) {
2513
			return;
2514
		}
2515
2516
		foreach ( $variations as $variation_id ) {
2517
			// Price fields
2518
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2519
			$sale_price    = wc_clean( $data['value'] );
2520
2521
			// Date fields
2522
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2523
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2524
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2525
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2526
2527
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2528
		}
2529
	}
2530
2531
	/**
2532
	 * Bulk action - Set Stock.