- This topic has 9 replies, 2 voices, and was last updated 3 years, 9 months ago by
David.
-
AuthorPosts
-
July 1, 2022 at 1:46 am #2270046
Ketil
Hi. Can I filter a hook to show by woocommerce endpoints?
July 1, 2022 at 4:12 am #2270132David
StaffCustomer SupportHi there,
woocommerce provides the
is_wc_endpoint_urltemplate 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
100is the ID of the GP Element. And if theis_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.
July 1, 2022 at 4:29 am #2270138Ketil
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
July 1, 2022 at 4:37 am #2270142David
StaffCustomer Supporthave you created your own template for
/my-endpoint?July 1, 2022 at 4:39 am #2270147Ketil
Yes, using an Elementor template by shortcode. Can be solved in the template, I guess.
July 1, 2022 at 5:07 am #2270160David
StaffCustomer SupportYes, 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.July 1, 2022 at 5:17 am #2270173Ketil
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?
July 1, 2022 at 5:56 am #2270207David
StaffCustomer SupportGP 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 ?July 1, 2022 at 6:37 am #2270239Ketil
“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
July 1, 2022 at 6:45 am #2270248David
StaffCustomer SupportOk, 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. -
AuthorPosts
- You must be logged in to reply to this topic.