Customizing WooCommerce myaccount endpoints with Sage 9

I just figured out how to customize the myaccount-pages of WooCommerce with Sage 9 and blade, and want to share it with anybody who might be looking for it, to save some time.

What’s needed:

Step 1
If not done already, adding WooCommerce support to app/setup.php:


Step 2
Copy the myaccount-php files from woocommerce/templates/myaccount/<filename.php> to resources/myaccount/<filename.php>.

Step 3
Create resources/views/myaccount/<filename.blade.php> and copy the content of resources/myaccount/<filename.php> to it.

Step 4
Replace the content of <filename.php> with

<?php echo \App\template('myaccount.<filename.blade.php>');

I decided to leave the

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly

in the .php file.

Step 5
You’re good to go! Sometimes, as with dashboard.php, some variables cannot be found (e.g. $current_user), but those are easy to replace. Other than that, I cannot find any errors with this approach so far.


Thank you! :ok_hand: