WPML: Sync post (product) status between languages

function wpml_replicate_status( $post_id ) {
        //get the post id the default language, in my case "en"
    $original_post    = icl_object_id ($post_id, "product", false, "en");
 
       //check if am editing the default language only and not child translations.
    if ( wp_is_post_revision( $post_id ) || $post_id != $original_post ) {
        return;
    }
 
    remove_action( 'save_post', 'wpml_replicate_status' );
    $original_post    = get_post( $post_id );
    $active_languages = apply_filters( 'wpml_active_languages', null, 'orderby=id&order=desc' );
    foreach ( $active_languages as $language ) {
        $translation_id = apply_filters( 'wpml_object_id', $original_post->ID, $original_post->post_type, false, $language["code"] );
        if ( $translation_id == $post_id ) {
            continue;
        }
        $updated_post = array(
            'ID'          => $translation_id,
            'post_status' => $original_post->post_status,
        );
        wp_update_post( $updated_post );
    }
    add_action( 'save_post', 'wpml_replicate_status' );
}
 
add_action( 'save_post', 'wpml_replicate_status' );