Code Duplication    Length = 19-19 lines in 2 locations

includes/class-wc-ajax.php 2 locations

@@ 2440-2458 (lines=19) @@
2437
	 * @param  array $variations
2438
	 * @param  array $data
2439
	 */
2440
	private static function variation_bulk_action_variable_regular_price( $variations, $data ) {
2441
		if ( ! isset( $data['value'] ) ) {
2442
			return;
2443
		}
2444
2445
		foreach ( $variations as $variation_id ) {
2446
			// Price fields
2447
			$regular_price = wc_clean( $data['value'] );
2448
			$sale_price    = get_post_meta( $variation_id, '_sale_price', true );
2449
2450
			// Date fields
2451
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2452
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2453
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2454
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2455
2456
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2457
		}
2458
	}
2459
2460
	/**
2461
	 * Bulk action - Set Sale Prices.
@@ 2467-2485 (lines=19) @@
2464
	 * @param  array $variations
2465
	 * @param  array $data
2466
	 */
2467
	private static function variation_bulk_action_variable_sale_price( $variations, $data ) {
2468
		if ( ! isset( $data['value'] ) ) {
2469
			return;
2470
		}
2471
2472
		foreach ( $variations as $variation_id ) {
2473
			// Price fields
2474
			$regular_price = get_post_meta( $variation_id, '_regular_price', true );
2475
			$sale_price    = wc_clean( $data['value'] );
2476
2477
			// Date fields
2478
			$date_from = get_post_meta( $variation_id, '_sale_price_dates_from', true );
2479
			$date_to   = get_post_meta( $variation_id, '_sale_price_dates_to', true );
2480
			$date_from = ! empty( $date_from ) ? date( 'Y-m-d', $date_from ) : '';
2481
			$date_to   = ! empty( $date_to ) ? date( 'Y-m-d', $date_to ) : '';
2482
2483
			_wc_save_product_price( $variation_id, $regular_price, $sale_price, $date_from, $date_to );
2484
		}
2485
	}
2486
2487
	/**
2488
	 * Bulk action - Set Stock.