Archived topic
Exclude elements from certain Woocommerce endpoints
7 replies · Started by mkjj on May 24, 2022
I've created an element to show a progress indicator on the Woocommerce cart and checkout page. Works perfectly fine. However, Wooccommerce creates some additional endpoints like /checkout/order-received/. This is not a page than can be selected in the element display settings. Do you an idea how I could exclude these endpoints?
Thank you, Mike
Hi there,
you can use the generate_element_display filter to change the display value for a specific element wit this snippet:
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 100 === $element_id && is_wc_endpoint_url( 'order-received' ) ) {
$display = false;
}
return $display;
}, 10, 2 );
Just change the 100 to the Elements ID.
Thank you very much! The element ID is 529079, and the endpoint URL is "bestellung-erhalten". So, this snippet goes into the functions.php
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 529079 === $element_id && is_wc_endpoint_url( 'bestellung-erhalten' ) ) {
$display = false;
}
return $display;
}, 10, 2 );
But the element is still there (the part below the main navigation):
https://www.agoshop.de/kasse/bestellung-erhalten/
What am I missing?
Does it work if you leave the slug as: order-received ?
Ah, my bad! Of course, this works. Actually, I tried it but had a typo in it. :-)
Thank you very much. Very elegant solution! Is there anything that is not possible with Generatepress? :-)
Well i am still trying to figure out how to get the Theme to pour me some coffee lol
Glad to be of help!
I'm sure, you will find a solution for that! :-)
Yeah - i am gonna text my son and ask him to some lol :)