Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check that we are not in a Woocommerce endpoint

since WooCommerce 2.1 pages such as order-received has been removed and replaced with WC endpoints. My checkout page had a custom page template (page-checkout.php) and now all checkout endpoints are also using this custom page template.

I need to modify my header and footer only when my customers are in the /checkout/ page, but I want to show different content when they are in a checkout endpoints. I have found this conditional:

if(is_wc_endpoint_url("order-received")) echo "yes";

It works when we are in the "order-received" checkout endpoint. But I am looking for a conditional logic that tells me when we are not in an endpoint, something like:

if(!is_wc_endpoint()) echo "yes";

Thank you.

like image 992
Pbinder Avatar asked Apr 24 '14 11:04

Pbinder


People also ask

Where are WooCommerce endpoints?

Endpoints are located at WooCommerce > Settings > Advanced.

Is WooCommerce an endpoint?

Endpoints are the key to making sure that your WooCommerce store runs smoothly. They are the specific URL structures that handle all of the different aspects of your store, from adding products to the cart, to processing payments, and everything in between.

How to edit checkout endpoints WooCommerce?

You can edit these endpoints by going to WooCommerce > Settings > Advanced > Endpoints. From here, you can add, remove, or change the slug for any of the default endpoints. Additionally, you can create new endpoints by clicking the “Add New Endpoint” button.

How do WooCommerce endpoints work?

WooCommerce documentation says, “Endpoints are an extra part in the website URL that is detected to show different content when present.” In plainer language, WooCommerce endpoints are extra URL slugs for your WooCommerce URL slugs.


1 Answers

The questions seemed to be answered and bit old. But i found a better solution, which may help somebody else.

you can use the following function. Documentation

is_wc_endpoint_url()

if used without a parameter, it will check current url against all endpoints. If an endpoint is specified like

is_wc_endpoint_url('edit-account');

it will check either the url is of specific endpoint or not.

like image 87
S. A. Malik Avatar answered Oct 01 '22 15:10

S. A. Malik