Code Duplication    Length = 19-26 lines in 2 locations

includes/wc-product-functions.php 2 locations

@@ 418-436 (lines=19) @@
415
	", current_time( 'timestamp' ) ) );
416
417
	if ( $product_ids ) {
418
		foreach ( $product_ids as $product_id ) {
419
			$regular_price = get_post_meta( $product_id, '_regular_price', true );
420
421
			update_post_meta( $product_id, '_price', $regular_price );
422
			update_post_meta( $product_id, '_sale_price', '' );
423
			update_post_meta( $product_id, '_sale_price_dates_from', '' );
424
			update_post_meta( $product_id, '_sale_price_dates_to', '' );
425
426
			$parent = wp_get_post_parent_id( $product_id );
427
428
			// Sync parent
429
			if ( $parent ) {
430
				// Grouped products need syncing via a function
431
				$this_product = wc_get_product( $product_id );
432
				if ( $this_product->is_type( 'simple' ) ) {
433
					$this_product->grouped_product_sync();
434
				}
435
			}
436
		}
437
438
		WC_Cache_Helper::get_transient_version( 'product', true );
439
		delete_transient( 'wc_products_onsale' );
@@ 374-399 (lines=26) @@
371
	", current_time( 'timestamp' ) ) );
372
373
	if ( $product_ids ) {
374
		foreach ( $product_ids as $product_id ) {
375
			$sale_price = get_post_meta( $product_id, '_sale_price', true );
376
377
			if ( $sale_price ) {
378
				update_post_meta( $product_id, '_price', $sale_price );
379
			} else {
380
				// No sale price!
381
				update_post_meta( $product_id, '_sale_price_dates_from', '' );
382
				update_post_meta( $product_id, '_sale_price_dates_to', '' );
383
			}
384
385
			$parent = wp_get_post_parent_id( $product_id );
386
387
			// Sync parent
388
			if ( $parent ) {
389
				// Clear prices transient for variable products.
390
				delete_transient( 'wc_var_prices_' . $parent );
391
392
				// Grouped products need syncing via a function
393
				$this_product = wc_get_product( $product_id );
394
395
				if ( $this_product->is_type( 'simple' ) ) {
396
					$this_product->grouped_product_sync();
397
				}
398
			}
399
		}
400
401
		delete_transient( 'wc_products_onsale' );
402
	}