get woocommerce My account page link

I am trying to send an email to customer after purchased products and when customer click on the the link provided the e

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="">
        <img src=".png" alt="Product Rating">
    </a>

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

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">
    </a>

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

Share Improve this question edited Jan 4, 2016 at 12:52 Ans asked Jan 4, 2016 at 12:46 AnsAns 4292 gold badges5 silver badges10 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 45

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">
</a>

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' ) ); ?>

Shop

<?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');
     <?php  
       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
        }
      ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742358090a4428840.html

相关推荐

  • get woocommerce My account page link

    I am trying to send an email to customer after purchased products and when customer click on the the link provided the e

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信