I recently submitted a pull request to WooCommerce core, which introduces an extra body class to the my account dashboard. This contribution has been reviewed, merged, and is scheduled for release in WooCommerce v9.5.0.
Table of Contents
No body class for account dashboard
As reported in WooCommerce issue #30050, when digging into the code of the my account section on the frontend of a WooCommerce store, each sub section of the account applies a body class associated with the sub section currently active, e.g. if you are on the orders sub section, you’ll see a woocommerce-orders
body class applied.
There is a woocommerce-account
class applied to all the my account pages, however, the account dashboard (before clicking through to any sub section) does not include its own class, and therefore if you want to apply custom my account styling solely on the account dashboard page, the only way to achieve this is by including multiple :not
body class CSS rules, like this and the rest:
.woocommerce-account:not(.woocommerce-downloads):not(.woocommerce-orders)
To make this easier a new body class has now been applied when on the my account dashboard page.
Adding the body class
My PR adds an additional body class of woocommerce-dashboard
when on the my account dashboard.
For the full technicals on this, see the pull request on the WooCommerce GitHub.
Review, merge, and release
The PR was kindly reviewed by NΓ©stor Soriano, and after some tweaks, it was merged into core WooCommerce.
It is on target for being included in WooCommerce v9.5.0, which should be released around November 2024.