-2

I'm running the latest version of WordPress (4.9.2) and WooCommerce (3.2.6) and I'm having issues overwriting the My Account template.

I've created a file in my theme:

theme-name/woocommerce/myaccount/my-account.php

I have a page in my WP Admin with the post_content set to:

[woocommerce_my_account]

However, when I open the link, http://example.com/en/my-account, it's showing the default index.php.

If I put the following code in my index, I get to see the account page:

do_shortcode('[woocommerce_my_account]');

I've also made sure that my WooCommerce account page is set to the right one in WooCommerce > Settings > Account > My Account Page.

I can see in the body of the rendered page that has the following classes

page-template-default page page-id-8 logged-in desktop woocommerce-account woocommerce-page

Does anyone know why it's not displaying the page properly?

6
  • Can whoever down voted the question explain the reason? :thinking_face:
    – Chin Leung
    Jan 21, 2018 at 14:12
  • With "it's showing the default index.php" you mean the WooCommerce part isn't shown, but the regular page content is? Have you tried disabling all other plugins and using one of the default themes, without your modifications?
    – swissspidy
    Jan 21, 2018 at 16:26
  • @swissspidy Yes exactly. Normally it should show the CooCommerce my account template instead of the theme's index.php.
    – Chin Leung
    Jan 21, 2018 at 23:10
  • What happens when you go to http://example.com/my-account/? What's your WordPress Address and Site Address settings in Settings > General?
    – Abhik
    Jan 22, 2018 at 4:46
  • 1
    downvoted since 1. WC is off-topic. 2. No code means that all answers can be no more than guesses. 3. Or in other words it is too localised and unlikely to be figured out without access to your server. 4. You put a bounty therefor the question can not be closed and the only avanue available is to downvote it (and please spare me the "but there are WC questions around here" argument) Jan 27, 2018 at 18:33

4 Answers 4

0

so do_shortcode('[woocommerce_my_account]'); is working in index.php and [woocommerce_my_account] is not working normal wp admin page.

have you tried looking for the issue with the_content() function? check if the loop is correct in your theme's template file.

0

Please make sure you have checked one of the following things:

  1. Have you mentioned theme support for woocommerce in your theme? add_theme_support('woocommerce')
  2. in dashboard go to status submenu inside woocommerce menu and check template overrides block if it is showing your template
  3. Please make sure on your page template, there is the_content() being called inside the loop.

Thanks!

2
  • add_theme_support('woocommerce') shouldn't be needed. I successfully tested this without it.
    – swissspidy
    Jan 23, 2018 at 11:54
  • @swissspidy you are right... it's just for letting WordPress know that theme supports Woo Commerce
    – Sachit
    Jan 23, 2018 at 11:58
0

I believe your problem it is not related to the shortcode or page template or index.php. It should work regardless.

I see you have a multilingual setup. You should look into how WooCommerce plays with this as it is not always easy. Most translation plugins (like WPML) have special helper plugin that ensures WooCommerce is playing nice with them.

-2

You should use echo when using do_shortcode. Change it to :

echo do_shortcode('[woocommerce_my_account]');

You can check more info about do_shortcode here : https://developer.wordpress.org/reference/functions/do_shortcode/ . Cheers!

1
  • That's not the problem at hand. They demonstrated that using do_shortcode() works. The bug is that the My Account page isn't working automatically.
    – swissspidy
    Jan 24, 2018 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.