Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

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