I have followed this answer How to add more custom field in Linked Product of Woocommerce to add a custom select field to my Linked Product screen in Woocommerce. This new field
This kind of select field only works with a defined multiple
attribute and work with an array of values. so you can't use it for a simple ID. If you add to your select field multiple="multiple"
attribute it will work.
Also since Woocommerce 3 things have changed:
- There are better hooks to save the data.
- You can now use CRUD Objects and related methods.
The following code will work for multiple product IDs (an array of products IDs):
// Display a custom select field in "Linked Products" section
add_action( 'woocommerce_product_options_related', 'display_linked_products_data_custom_field' );
function display_linked_products_data_custom_field() {
global $product_object, $post;
?>
update_meta_data( '_subscription_toggle_ids', $data );
}
Code goes in function.php file of your active child theme (active theme). Tested and works.