dungey_140
dungey_140

Reputation: 2792

WooCommerce conditional statements

I am trying to conditionally show some content based on a few Woocommerce conditionals.

I want to show content when:

  1. Not on a product page

  2. Not on the checkout page

  3. But, on the order received checkout endpoint

The below code is not quite working, the first 2 work correctly but the endpoint doesn't seem to work as it is part of the checkout page? Any ideas how to adjust?

<? if( !is_product() && !is_checkout() && is_wc_endpoint_url('order-received' ): ?>
MY CONTENT
<? endif ?>

Upvotes: 1

Views: 139

Answers (1)

Matts
Matts

Reputation: 1341

If the endpoint is conditional on is_checkout() being true, you could adjust it with an OR condition within brackets so it'll evaluate to true. If both are false the content won't show, but if either one is true it will, assuming !is_product() is true.

<? if( !is_product() && (!is_checkout() || is_wc_endpoint_url('order-received' )): ?>

Upvotes: 1

Related Questions