Code Duplication    Length = 17-17 lines in 2 locations

includes/data-stores/class-wc-product-grouped-data-store-cpt.php 1 location

@@ 26-42 (lines=17) @@
23
	 * @param bool       $force Force update. Used during create.
24
	 * @since 3.0.0
25
	 */
26
	protected function update_post_meta( &$product, $force = false ) {
27
		$meta_key_to_props = array(
28
			'_children' => 'children',
29
		);
30
31
		$props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props );
32
33
		foreach ( $props_to_update as $meta_key => $prop ) {
34
			$value   = $product->{"get_$prop"}( 'edit' );
35
			$updated = update_post_meta( $product->get_id(), $meta_key, $value );
36
			if ( $updated ) {
37
				$this->updated_props[] = $prop;
38
			}
39
		}
40
41
		parent::update_post_meta( $product, $force );
42
	}
43
44
	/**
45
	 * Handle updated meta props after updating meta data.

includes/data-stores/class-wc-product-variation-data-store-cpt.php 1 location

@@ 458-474 (lines=17) @@
455
	 * @param WC_Product $product Product object.
456
	 * @param bool       $force Force update. Used during create.
457
	 */
458
	public function update_post_meta( &$product, $force = false ) {
459
		$meta_key_to_props = array(
460
			'_variation_description' => 'description',
461
		);
462
463
		$props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props );
464
465
		foreach ( $props_to_update as $meta_key => $prop ) {
466
			$value   = $product->{"get_$prop"}( 'edit' );
467
			$updated = update_post_meta( $product->get_id(), $meta_key, $value );
468
			if ( $updated ) {
469
				$this->updated_props[] = $prop;
470
			}
471
		}
472
473
		parent::update_post_meta( $product, $force );
474
	}
475
476
	/**
477
	 * Update product variation guid.