1

Current Woocommerce version under our usage is 2.5.5 I am using following shortcode inside my edit account page.

[woocommerce_edit_account]

But, my page shows home page instead of edit account page. Is some thing new now ?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
laraib
  • 611
  • 5
  • 16

3 Answers3

1

They don't work anymore, they're only for Woocommerce 2.1 or less. They have been replaced with endpoints, so you would need to do something like this:

$my_account_link = get_permalink( get_option('woocommerce_myaccount_page_id') );
$edit_acount_link = $my_account_link . '/edit-account';

If the first line is too long try with this:

$my_account_link = get_bloginfo('url'). '/my-account';

You can read more information about endpoints at: https://docs.woothemes.com/document/woocommerce-endpoints-2-1/

Skatox
  • 4,237
  • 12
  • 42
  • 47
  • I not just want to show link, I Want to show when ever user clicks on or reaches in other words at edit account page he/she will be able to edit his/her account. Will your code provide that one ? additionally, where will I put this code ? i was trying to use shortcode inside page editer but your code will not run there .... any thing more plzzz – laraib May 10 '16 at 14:36
  • You can put this code in a custom shortcode or in any hook/filter to do what you want. – Skatox May 10 '16 at 15:43
  • @laraib I believe what you are looking for is in my answer to this other question: https://stackoverflow.com/questions/54328856/woocommerce-edit-account-shortcode – Maira Bay Jul 19 '19 at 20:29
1

You can use instead the native WooCommerce function wc_customer_edit_account_url().
(It's used in woocommerce my_account.php template too).

As Skatox mention it, [woocommerce_edit_account] doesn't work anymore.

You can use it with a custom self closing shortcode:

// Paste this in the function.php file of your active child theme or theme.
function wc_customer_edit_account_shortcode( $atts ) {

    // Attributes
    $atts = shortcode_atts(
        array(
            'text' => '',
        ),
    );

    return '<a class="customer-edit-account" href="'.wc_customer_edit_account().'">'.$text.'</a>';

}
add_shortcode( 'wc_customer_edit_account', 'wc_customer_edit_account_shortcode' );

Use: [wc_customer_edit_account text="Editing my account details" /]

Community
  • 1
  • 1
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
0

On my site (with WooCommerce 3.6.5) this is the code that worked for me:

// Paste this in the function.php file of your active child theme or theme.
function wc_customer_edit_account_shortcode( $atts ) {

    // Attributes
    extract( shortcode_atts( array(
                'text' => 'Edit Account' ), $atts ) );

    return '<a class="customer-edit-account" href="'.wc_customer_edit_account_url().'">'.$text.'</a>';

}
add_shortcode( 'wc_customer_edit_account', 'wc_customer_edit_account_shortcode' );

Instead of editing the function.php or even adding a child theme, I pasted it in a New Snippet using the Snippets plugin.

Maira Bay
  • 300
  • 5
  • 8