Site logo

[Resolved] Woocommerce endpoints

Home Forums Support [Resolved] Woocommerce endpoints

Home Forums Support Woocommerce endpoints

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2270046
    Ketil

    Hi. Can I filter a hook to show by woocommerce endpoints?

    #2270132
    David
    Staff
    Customer Support

    Hi there,

    woocommerce provides the is_wc_endpoint_url template tag.
    Heres an example using that with a GP Element.

    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 );

    the 100 is the ID of the GP Element. And if the is_wc_endpoint_url( 'order-received' ) condition is met then the Element will be disabled ( $display = false; )

    If you have a specific requirement let me know.

    #2270138
    Ketil

    I made a custom endpoint for easy access to some extra functions I have added to site. Just to make it easy to find for the customers. I wanted to create a hooks in order to display some extra admin-options for this endpoint, active only for /my-account/my-endpoint

    #2270142
    David
    Staff
    Customer Support

    have you created your own template for /my-endpoint ?

    #2270147
    Ketil

    Yes, using an Elementor template by shortcode. Can be solved in the template, I guess.

    #2270160
    David
    Staff
    Customer Support

    Yes, you would need to include that in the template.
    If its built with Elementor then GP hooks won’t work as they do not exist outside of the theme templates.

    #2270173
    Ketil

    The initial idea was to show these admin options as a hook not connected to the page content, like you can for regular pages and posts, the content of the page/post can be Elementor, but you can still hook “after content” etc. I guess you can hook the page “my-account”, but it will show no matter what endpoint is navigated, right?

    #2270207
    David
    Staff
    Customer Support

    GP doesn’t add Woocommerce templates, it leaves that to the Woo plugin.
    So you need to check which template is being used. How did you create the endpoint template ?

    #2270239
    Ketil

    “My account” is not a Woocommerce template as such, it’s a regular page with a shortcode in it. But nevermind, I’ll solve it in the template instead of by a hook

    #2270248
    David
    Staff
    Customer Support

    Ok, no problem, it make the most sense to edit the page/template if its accessible.
    Hooks are good for when you can’t do that.

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