WooCommerce Conditional Tags
Conditional tags are PHP functions that return true or false for the current request. Use them to check which WooCommerce page a visitor is viewing.
Six useful conditional tags
| Function | Returns true when | Useful detail |
|---|---|---|
is_shop() |
The main shop archive is displayed. | Not a test for every WooCommerce page. |
is_product() |
A single product page is displayed. | Does not match the shop or product category archives. |
is_product_category() |
A product category archive is displayed. | Pass a category slug, such as 'shirts', to check one category. |
is_cart() |
The configured cart page is displayed. | Checks page context, not whether the cart has items. |
is_checkout() |
The checkout page is displayed. | Checks page context, not whether an order was completed. |
is_account_page() |
A WooCommerce My Account page is displayed. | Use endpoint checks when a particular account view matters. |
Timing and common mistakes
- Check after the query is ready. WooCommerce's conditional-query functions should be evaluated after WordPress resolves the request; the
wpaction is a safe early point. Callingis_product()directly asfunctions.phploads may returnfalseeven on a product page. - Don't confuse page and content checks.
is_shop()checks the main product archive, whileis_product()checks one product.is_product_category( 'shirts' )tests the category slug, not its visible label. - Don't treat conditions as insertion points. A conditional tag identifies page context; an action or filter hook controls when your callback runs or which value it changes. Classic-template hooks may not apply to block-based layouts.
- Don't use
is_woocommerce()as an all-pages shortcut. It is not a reliable substitute for the dedicated cart and checkout checks.
For the full function list and details, see the official WooCommerce conditional tags reference. Return to the WooCommerce developer reference for other categories.