WC_Brands::duplicate_store_temporary_brandspublicWC 1.0

Temporarily tag a post with meta before it is saved in order to allow us to be able to use the meta when the product is saved to add the brands when an ID has been generated.

Method of the class: WC_Brands{}

No Hooks.

Returns

WC_Product. $original

Usage

$WC_Brands = new WC_Brands();
$WC_Brands->duplicate_store_temporary_brands( $duplicate, $original );
$duplicate(WC_Product) (required)
.
$original(required)
.

WC_Brands::duplicate_store_temporary_brands() code WC 10.4.3

public function duplicate_store_temporary_brands( $duplicate, $original ) {
	$terms = get_the_terms( $original->get_id(), 'product_brand' );
	if ( ! is_array( $terms ) ) {
		return;
	}

	$ids = array();
	foreach ( $terms as $term ) {
		$ids[] = $term->term_id;
	}
	$duplicate->add_meta_data( 'duplicate_temp_brand_ids', $ids );
}