Synchronizing custom taxonomies on Product Synchronization
By default, on Product Synchronization all product data will be migrated to the designated shops in the network. That includes the Product Category and Product Tag taxonomies.
When using custom taxonomies, to synchronize a custom one called ‘writer’ from the main product to its child products across different shops within a multi-site WooCommerce network, a custom code can be used.
The $taxnomy_name variable value should be updated accordingly to the actual local taxonomy name.
add_filter( 'woogc/ps/synchronize_product/child_product', 'sync_custom_taxonomy_to_child_product', 10, 3 ); function sync_custom_taxonomy_to_child_product( $child_product, $main_product_data, $origin_product_blog_ID ) { $taxnomy_name = 'writer'; //switch back to the origin product shop switch_to_blog( $origin_product_blog_ID ); $main_product = new WC_Product( $main_product_data[ 'id' ] ); $main_product_terms_ids = wp_get_object_terms( $main_product->get_ID(), $taxnomy_name, array( 'fields' => 'ids' ) ) ; restore_current_blog(); if ( count ( $main_product_terms_ids ) > 0 ) { $WooGC_PS = new WooGC_PS(); $WooGC_PS->synchronize_taxonomy ( $main_product_terms_ids, $child_product->get_ID(), $origin_product_blog_ID, $taxnomy_name ); } return $child_product; }
The code should be placed inside theme functions.php or a custom file within /wp-content/mu-plugins/
Synchronizing custom taxonomies across multi-site WooCommerce networks ensures consistency and coherence in product management.