Site logo

Archived topic

GP Elements Display Rule Woocommerce checkout subpages

3 replies · Started by Manuel on March 11, 2022

Viewing posts 1–4 of 4

Hello,

how can i exclude for example an GP element for woocommerce subpages like checkout/order-received.

So basically what I am trying to achieve is to remove/add some GP elements on the checkout page of woocommerce. For this I am using the display rule Location: 'Page' -> 'checkout'.

After the user submits the order, he will be redirected to the 'checkout/order-received' page. But on this page the display rules should no longer apply.
But actually i am not able to exclude an GP element with a filter like Exclude: 'Page' -> 'checkout' -> 'order-received'

Can you help me here?

Hi there,

you can use this PHP 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 );

Note the 100 needs to be changed to the ID of your Element

Hello David,
thank you very much.
Your solution works perfectly. Do you know if there is a plan to integrate this into the display rules editor? So that it is not necessary to add this functionality as code?

You can imagine that this makes the whole thing confusing, since the visibility of an element is controlled in 2 different places.

It might be something we incorporate in a future update. I have made a note :)

Glad to be of help

This archived topic is closed to new replies.