How to check WooCommerce thank you page

Viewed 16162

In Wordpressis_page() can check page by ID,name or by slug but how can we check WooCommerce thank you page whether its a part of checkout page.

Also We have a lot of WooCommerce conditional tags but cant find something solve my issue

for example I try

if(is_page('checkout')) {
   //some thing for only checkout page
}else if(is_page('thankyou') && !is_page('checkout')){
  //some thing for only thank you page but not on checkout page
}else{
  //some thing for all other page
}
2 Answers

This sample code may work:

if ( is_checkout() && !empty( is_wc_endpoint_url('order-received') ) ) {
    ...
}

I think better to use endpoint like

if ( is_wc_endpoint_url( 'order-received' ) ) {
global $wp;
//Get Order ID
$current_order_id =  intval( str_replace( 'checkout/order-received/', '', $wp->request ) );
echo $current_order_id;
}
Related