Site logo

Archived topic

How to insert an element at the top (order received) page?

1 reply · Started by Deyaa on December 30, 2021

Viewing posts 1–2 of 2

Hi there,

How to insert an element at the top (order received) page?

Hi there,

the order-received is an endpoint for the Checkout page not a separate page.
Which means you need to:

1. Set your Element Display Rule Location to Checkout.
2. Use a filter to make it only display on the order received endpoint. Add this PHP Snippet:

add_filter( 'generate_element_display', function( $display, $element_id ) {
    if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
        return $display;
    }

    if ( 123 == $element_id && !is_wc_endpoint_url( 'order-received' ) ) {
        return false;
    }

    return $display;
}, 10, 2 );

123 needs to be changed to the ID of the Element. Which can be found in the browser URL field when editing the element.

This archived topic is closed to new replies.