Maged Mohamed
Maged Mohamed

Reputation: 561

Change view button text in Woocommerce My account orders table

I would like to customize My account > Orders page, changing from action column, the "view" button text to "view tickets" in the Orders list table.

Is it possible to do it only on My account > Orders page?

Here is a screenshot for clarifications:

enter image description here

Upvotes: 2

Views: 3373

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253784

To rename My account > Orders: "view" action button text, use the following:

// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
    $actions['view']['name'] = __( 'View ticket', 'woocommerce' );

    return $actions;
}

To Rename My account "Orders" menu item, use the following (if needed):

// Rename My account "Orders" menu item
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_orders_menu_item', 22, 1 );
function rename_my_account_orders_menu_item( $items ) {
    $items['orders'] = __("Ticket Orders", "woocommerce");

    return $items;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

enter image description here


If you need to target only My account > "orders" table, use is_wc_endpoint_url('orders') conditional tag:

// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
    if( is_wc_endpoint_url( 'orders' ) ) 
        $actions['view']['name'] = __( 'View ticket', 'woocommerce' );

    return $actions;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Upvotes: 6

Related Questions