This should work. Untested though.
I don’t know how you get $woocomerce_wookc_text
, but since you mentioned CMB, I am taking you are saving it as product meta data
function wpse405916_add_to_cart( $cart_item_key, $product_id ) {
//Get the woocomerce_wookc_text value.
$woocomerce_wookc_text = get_post_meta( $product_id, 'woocomerce_wookc_text ', true );
//Check if the value exists
if ( $woocomerce_wookc_text && !empty($woocomerce_wookc_text) ) {
//Set the value as integer
$woocomerce_wookc_text = (int)$woocomerce_wookc_text;
//Add it to cart
WC()->cart->add_to_cart($woocomerce_wookc_text);
}
}
add_action( 'woocommerce_add_to_cart', 'wpse405916_add_to_cart', 10, 2 );
This will automatically add the product associated with the id from $woocomerce_wookc_text
when the main product is added to cart. There are numerous checks should be added.