最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

get woocommerce My account page link

programmeradmin0浏览0评论

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
        }
      ?>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论