Using wc_get_template for custom my account page after 2.6 update.
-
Hi, thanks for the wonderful work on WC!
Before 2.6 I was able to build my own “tabbed” My Account page by using
remove_action
to remove hooked sections, and then by usingwc_get_template()
to insert all the my account template parts into my “tab” containers.After the update to 2.6 I am finding that the current user and/or user id is not getting passed to the WC template parts. For example when I use
wc_get_template( 'myaccount/orders.php' );
in my custom myaccount.php template file, no orders display for users who I know have past orders.Also for the
myaccount/form-edit-account.php
template part, the user’s name and email were not populating their respective fields. So I tried the following:$user = wp_get_current_user(); wc_get_template( 'myaccount/form-edit-account.php', array( 'user' => $user, ) );
The above worked for the
form-edit-account.php
, successfully populating the fields with the current user’s info, but did not solve the issue with theorders.php
template, which was still blank.It seems like perhaps each template part requires a different set of parameters to be passed, in order to render properly, but I can’t seem to figure out which template part requires which parameters. Is there documentation on that?
I would like to continue using my own tabs because no page reload is required to access each tab’s content. But I would like my template to be totally compliant with the latest WC customization standards. So if you think I could accomplish my goal in a better way, I am open to suggestions.
I hope I have communicated my problem well. Please let me know.
Basically I would like to be able to manually insert any and all myaccount template parts into specific locations in my custom template, making sure that all template parts render correctly with the current user’s information.
Thanks in advance for your help!
- The topic ‘Using wc_get_template for custom my account page after 2.6 update.’ is closed to new replies.