If you want to do the processing and reloading, more or less, user not noticing, you could execute a custom function on template_redirect
action.
function check_parameter() {
if ( isset( $_GET['bar'] ) && 'foo' === $_GET['bar'] && is_singular( 'product' ) ) {
// get remote data e.g. with wp_remote_get( 'http://example.com' );
// do something
// redirect
global $wp;
wp_redirect( home_url( $wp->request ) ); // this should redirect to the same url without parameters
die;
}
}
add_action( 'template_redirect', 'check_parameter' );
If you want to show the user that something is happening, then you could use admin ajax (or wp rest api). Something like this,
PHP
add_action( 'wp_ajax_my_action', 'my_action_function' );
add_action( 'wp_ajax__nopriv_my_action', 'my_action_function' ); // for non logged in users, if needed
function my_action_function() {
// check nonce
// check for capabilities, if needed
// check for required $_POST parameters / values
// do something
wp_send_json_error( $data );
// or
wp_send_json_success( $data ); // $data could be the new price for example
}
jQuery (use js if you prefer)
jQuery.ajax({
method: 'POST',
url: 'admin-ajax.php', // use wp_localize_script for this
data: {
action: 'my_action',
nonce: 'your-nonce-field-value', // use wp_localize_script for this
bar: 'foo', // use js/jquery to get url parameter(s)
},
success: function(response){
// do something with response.data
},
});