Skip to main content

Check if current page is checkout or cart one in WooCommerce

As a store owner or a developer, you want to make sure that customers are taken through the buying process in a smooth and organized way. In WooCommerce, there are two different types of pages that can be used as checkouts: the checkout page and the cart page. In this post, we’ll show you how to check which type of page your current view is so that you can ensure that you are injecting custom functions to the right page. Let’s get started!

WooCommerce provides 3 functions to detect respective pages.

//check out page
if(is_checkout()){ }
//cart page
if(is_cart()){ }
//store page
if(is_shop()){ }

If you want to use default WordPress functions, use is_page() instead!

if (is_page('cart')){} 
if (is_page('checkout')){}

By continuing to use the site, you agree to the use of cookies.