A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Conditional Tags

The conditional tags of Classic Commerce (and ClassicPress) can be used in your template files to change the content that is being displayed based on some conditions the page matches. For example, you may want to display a snippet of text above the shop page. You can do this by using the is_shop() conditional tag.

Because Classic Commerce uses custom post types, you can also use many of the ClassicPress conditional tags.

Note: You can only use conditional query tags after the posts_selection action hook in ClassicPress (the wp action hook is the first one through which you can use these conditionals). For themes, this means the conditional tag will never work properly if you are using it in the body of functions.php.


Available Conditional Tags

All conditional tags test whether a condition is met, and then return either TRUE or FALSE. Conditions under which tags output TRUE are listed below the conditional tags.

The list below shows the main conditional tags.

Classic Commerce page

is_woocommerce()
Returns true if on a page which uses Classic Commerce templates (cart and checkout are standard pages with shortcodes and thus are not included).

Main shop page

is_shop()
Returns true when on the product archive page (shop).

Product category page

is_product_category()
Returns true when viewing a product category archive.
is_product_category( 'shirts' )
When the product category page for the ‘shirts’ category is being displayed.
is_product_category( array( 'shirts', 'games' ) )
When the product category page for the ‘shirts’ or ‘games’ category is being displayed.

Product tag page

is_product_tag()
Returns true when viewing a product tag archive
is_product_tag( 'shirts' )
When the product tag page for the ‘shirts’ tag is being displayed.
is_product_tag( array( 'shirts', 'games' ) )
When the product tag page for the ‘shirts’ or ‘games’ tags is being displayed.

Single product page

is_product()
Returns true on a single product page. Wrapper for is_singular.

Cart page

is_cart()
Returns true on the cart page.

Checkout page

is_checkout()
Returns true on the checkout page.

Customer account pages

is_account_page()
Returns true on the customer’s account pages.

Endpoint

is_wc_endpoint_url()
Returns true when viewing a Classic Commerce endpoint
is_wc_endpoint_url( 'order-pay' )
When the endpoint page for order pay is being displayed.
is_wc_endpoint_url( 'order-received' )
When the endpoint page for order received is being displayed.
is_wc_endpoint_url( 'view-order' )
When the endpoint page for view order is being displayed.
is_wc_endpoint_url( 'edit-account' )
When the endpoint page for edit account is being displayed.
is_wc_endpoint_url( 'edit-address' )
When the endpoint page for edit address is being displayed.
is_wc_endpoint_url( 'lost-password' )
When the endpoint page for lost password is being displayed.
is_wc_endpoint_url( 'customer-logout' )
When the endpoint page for customer logout is being displayed.
is_wc_endpoint_url( 'add-payment-method' )
When the endpoint page for add payment method is being displayed.

Ajax request

is_ajax()
Returns true when the page is loaded via ajax.