How to add code to Woocommerce Subscriptions template

I wish the Woocommerce Subscriptions plugin would provide comprehensive details on how to amend the layouts in various sections. Some of the documentation on classes and their uses gives a hint of how to interact with different parts of this large codebase but it was difficult to find out how to make changes to certain pages a client was asking for.

The only way that worked for me was to drill down to the templates in the /woocommerce-subscriptions/templates folder and find the file I wanted under myaccount. Once in the subscription-details.php file I could see the do_action references and then write code to add rows to the table.

Code A

There are a few of these do_actions in the file. As can be seen the do_action output needs to fit in with the table structure although it would be possible to end the table, add custom content and then start a new table

And then how to add some custom content into the do_action placeholder? This is actually better documented with plenty of examples online on how to hook into the action as shown below.

Code B

This code is added to the __construct function of my class and calls the my_account_subscription_message function when triggered. The class needs instantiating to fire the add_action hook so somewhere in the code there needs to be a call to create an instance of the class eg $class = new class_name();

Code C

Anything can be printed from the hook but it is most likely something can be derived from the $subscription object sent to the hook.

This site provides an excellent full listing of methods available from the WC_Subscription object which should be somewhere on the Woocommerce site.