I am trying to send an email to customer after purchased products and when customer click on the the link provided the email for rating the product it should redirect to customer's account/My account page.
I put some code in functions.php to get the WooCommerce My Account URL:

$myaccount_page = get_option( 'woocommerce_myaccount_page_id' );
if ( $myaccount_page ) {
  $myaccount_page_url = get_permalink( $myaccount_page );

I have customized into customer-completed-order.php and put this code

    <h2> Go to your account page for review </h2>
    <a href="http://animax.cf/product/happy-ninja/#reviews">
        <img src="http://animax.cf/wp-content/uploads/2015/12/product-reviews.png" alt="Product Rating">

I want to get woocomerce myaccount url in above code. how should i do this.

5 Answers 5


You can get the WooCommerce my-account URL as below

<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account',''); ?>"><?php _e('My Account',''); ?></a>

Now you can insert this in completed order mail template too.

<h2> <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account',''); ?>">Go to your account page for review</a> </h2>
<a href="http://animax.cf/product/happy-ninja/#reviews">
    <img src="http://animax.cf/wp-content/uploads/2015/12/product-reviews.png" alt="Product Rating">
  • Actually i am beginner in php and wordpress. So, thank you very much WPTC-Troop.
    – Ans
    Jan 4, 2016 at 13:27
  • 28
    Instead of using get_option and get_permalink, just use WC's function for this: wc_get_page_permalink( 'myaccount' )
    – David
    Oct 31, 2017 at 21:08

woocommerce wc_get_page_id function will help you to create WooCommerce pages URLs

Examples of usage:

My Account

<?php echo get_permalink( wc_get_page_id( 'myaccount' ) ); ?>


<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?>

There is another way to do this using the WooCommerce native endpoints (you can use any of the registered endpoints with WC or third-party plugins that hook into WC): <?php echo esc_url( wc_get_account_endpoint_url( 'edit-account' ) ); ?>

For dashboard you could use something like this <?php echo esc_url( trailingslashit( wc_get_account_endpoint_url( '' ) ) ); ?>


It returns account page itself without endpoints:

echo wc_get_account_endpoint_url('dashboard');
       if ( is_front_page() && is_home() ) {
        // Default homepage
        echo "Default homepage";

        } elseif ( is_front_page()){

            echo "Static homepage";
        // Static homepage

        } elseif ( is_home()){
            echo "Blog page";
        // Blog page

        } elseif ( is_page( 'cart' ) || is_cart()){
            echo "cart";
        // Blog page

        }  elseif (is_single()){
            echo "is_single";
        // Blog page

        } elseif (is_product_category()){
            echo "is_product_category";
         else {
        echo "Everything else";
        // Everything else
  • 1
    Please edit your answer, and add an explanation: why could that solve the problem?
    – fuxia
    Jul 15, 2019 at 9:23

Your Answer

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

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