Some agencies require correct URLs to measure conversions, installing pixels, events, and scripts. This is not a difficult task when using the Google Tag Manager platform.
Some developers and designers find WooCommerce’s post-purchase page a bit rigid, so we decided to create a code snippet that redirects users to a desired page:
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom' );
function bbloomer_redirectcustom( $order_id ) {
$order = wc_get_order( $order_id );
$url = 'https://exemplo.com.br';
if ( ! $order->has_status( 'failed' ) ) {
wp_safe_redirect( $url );
exit;
}
}
Copy and paste the code above into your functions.php
file.
Remember to replace the example URL with the one you want!