This is very easy to do. What you want to do is hook into the customize_save_after action hook – https://developer.wordpress.org/reference/hooks/customize_save_after/ – and check your setting and based on it update another. Example:
add_action( 'customize_save_after', function() {
// Get the setting you want to retrieve value from
$new_value_setting_1 = get_theme_mod( 'SETTING_ID' );
// Update another setting
if ( $new_value_setting_1 ) {
set_theme_mod( 'SETTING_ID', $new_value_setting_1 );
}
// Delete theme mod if setting is empty rather then storing an empty value
else {
remove_theme_mod( 'SETTING_ID', $new_value_setting_1 );
}
} );
So whenever the customizer settings are changed the other setting is updated. Unfortunately doing it in the Customizer when the setting is changed won’t be possible without JS (from what I know) if you want to do it with PHP you should be hooking into customize_save_after.
That is unless…if the setting you are checking for uses the refresh method so when it’s modified the Customizer window refreshes, then you can hook into init to change the value..like this:
add_action( 'init', function() {
// Only needed in the customizer
if ( ! is_customize_preview() ) {
return;
}
// Get the setting you want to retrieve value from
$new_value_setting_1 = get_theme_mod( 'SETTING_ID' );
// Update another setting
if ( $new_value_setting_1 ) {
set_theme_mod( 'SETTING_ID', $new_value_setting_1 );
}
// Delete theme mod if setting is empty rather then storing an empty value
else {
remove_theme_mod( 'SETTING_ID', $new_value_setting_1 );
}
} );
I hope this helps!