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
}
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.
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.
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/…”.
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With