[Resolved] Exclude elements from certain Woocommerce endpoints

Home Forums Support [Resolved] Exclude elements from certain Woocommerce endpoints

Home Forums Support Exclude elements from certain Woocommerce endpoints

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2230683
    mkjj

    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

    #2230748
    David
    Staff
    Customer Support

    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.

    #2230783
    mkjj

    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?

    #2230828
    David
    Staff
    Customer Support

    Does it work if you leave the slug as: order-received ?

    #2230835
    mkjj

    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? πŸ™‚

    #2230849
    David
    Staff
    Customer Support

    Well i am still trying to figure out how to get the Theme to pour me some coffee lol

    Glad to be of help!

    #2230853
    mkjj

    I’m sure, you will find a solution for that! πŸ™‚

    #2230883
    David
    Staff
    Customer Support

    Yeah – i am gonna text my son and ask him to some lol πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.