Alert after checkout with woocommerce from function.php

  php, wordpress

I’m using woocommerce to take appointement, I know it kind a weird but it’s perfect for this project.

After the checkout, I redirect the user to the home page and I want to display an alert or a bar to say "Message send successfully"

How can I manage that from function.php ?

Code from my function.php :

function woocommerce_redirect_after_checkout() {
global $wp;

if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {

    global $woocommerce;
    
    $woocommerce->cart->empty_cart();
    
    wp_redirect(get_home_url() );
    
    //HERE echo '<script>alert('bla')</script>';

exit;
}

}

Thx

Source: Ask PHP

LEAVE A COMMENT