S
S
shamanle2021-04-19 05:29:43
WooCommerce
shamanle, 2021-04-19 05:29:43

How to make 2 woocommerce thank you pages?

I'm trying to send a client with an order amount of less than 5000 rubles to the thank you page No. 1, and a client who purchased more than 5000 rubles to the thank you page No. 2.
I use this code and it doesn't work

add_action( 'woocommerce_thankyou', 'redirectcustom');
 
function redirectcustom() {
    $totalOrder = WC()->cart->get_cart_contents_total();
  $minimum = 5000;
    if ( $totalOrder < $minimum ) {
     $url = '/thank-you-page-min/';
    } elseif (  $totalOrder > $minimum ) {
     $url = '/thank-you-page-max/';
    }
else {
//    $url = '/woocommerce-thank-you-page/';
    $url = '/';
} 
    if ( $order->status != 'failed' ) {
        wp_redirect($url);
        exit;
    }
  
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question