WC_Brands::duplicate_store_temporary_brands()
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.
Return
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() WC Brands::duplicate store temporary brands code WC 9.5.1
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 ); }