Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2468-2486 (lines=19) @@
2465
	 * @param  array $variations
2466
	 * @param  array $data
2467
	 */
2468
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2469
		if ( ! isset( $data['value'] ) ) {
2470
			return;
2471
		}
2472
2473
		foreach ( $variations as $variation_id ) {
2474
			// Price fields
2475
			$regular_price = wc_clean( $data['value'] );
2476
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2477
2478
			// Date fields
2479
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2480
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2481
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2482
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2483
2484
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2485
		}
2486
	}
2487
2488
	/**
2489
	 * Bulk action - Set Sale Prices.
@@ 2495-2513 (lines=19) @@
2492
	 * @param  array $variations
2493
	 * @param  array $data
2494
	 */
2495
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2496
		if ( ! isset( $data['value'] ) ) {
2497
			return;
2498
		}
2499
2500
		foreach ( $variations as $variation_id ) {
2501
			// Price fields
2502
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2503
			$sale_price    = wc_clean( $data['value'] );
2504
2505
			// Date fields
2506
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2507
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2508
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2509
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2510
2511
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2512
		}
2513
	}
2514
2515
	/**
2516
	 * Bulk action - Set Stock.