Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check WooCommerce thank you page

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
}
like image 548
Firefog Avatar asked Sep 08 '18 12:09

Firefog


People also ask

How do I view my thank you page in WooCommerce?

Click on WooCommerce > Settings from the left-hand sidebar. Click on the Checkout tab from the top of the Settings page. Scroll down to the “Thank You” Page section and select the page you want to use as your Thank You page from the dropdown menu.

How do I check my thank you page?

Both of is_order_received_page() and is_wc_endpoint_url( 'order-received' ) will work to check if you are on the thankyou page in the frontend.

Where is WooCommerce thank you page URL?

It is the page in which consumers are able to see right after their form submission. To be more specific, the thank you page URL in WooCommerce will come with the format by default as follow: “…/checkout/order-received/…”.

Does WooCommerce have a thank you page?

The default WooCommerce thank you page As you can see, the content is relatively basic. The order number, date, customer email, total, payment method, products purchased, and billing information are included by default. Let's explore some ways we can add some basic customizations to improve the thank you page.


2 Answers

This sample code may work:

if ( is_checkout() && !empty( is_wc_endpoint_url('order-received') ) ) {
    ...
}
like image 77
Kelvin Mariano Avatar answered Oct 19 '22 17:10

Kelvin Mariano


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;
}
like image 33
Khandaker Toihidul Islam Avatar answered Oct 19 '22 17:10

Khandaker Toihidul Islam