Skip to content
Advertisement

Detect dashboard of WooCommerce “my account” pages

How can I detect if the “myaccount/my-account.php” template is used on the Dashboard.

Currently I use:

JavaScript

But that feels kind of hacky. Isn’t there something like a is_myaccount_dashboard() function?

Advertisement

Answer

Update: Detecting specifically the My account “Dashboard” page

JavaScript

Tested and works.


Original answer:

Yes of course there is is_account_page() native WooCommerce conditional that returns true on the customer’s account pages.

Here is an example using is_account_page() and is_user_logged_in(). To get the my account link url you can use: get_permalink( get_option('woocommerce_myaccount_page_id') ).

JavaScript

Reference:


After that you can Override WooCommerce Templates via a Theme using my account templates to fine tune even more WooCommerce behaviors…

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement