I want to remove the URL from the WooCommerce My account Orders page and I really don't know how to do it by editing functions.php. Does anyone have any suggestions? Thank you!
I tried some of the answers I found on StackOverflow but I doesn't seem to work.
CodePudding user response:
Add this to your functions.php for the theme:
function remove_order_link( $actions, $order ) {
unset( $actions['view'] );
return $actions;
}
add_filter( 'woocommerce_my_account_my_orders_actions', 'remove_order_link', 10, 2 );
It will remove the "View" link from the "My account > Orders" page.
CodePudding user response:
Remove the existing order-number column using the first hook as it prints the order number along with the link. Add a custom order order-number column to print as per your requirement using the second hook
function remove_defualt_order_number_column($columns) {
unset($columns['order-number']);
$custom_order_number = array('order-number-custom' => __('Order', 'woocommerce'));
$columns = array_merge($custom_order_number, $columns);
return $columns;
}
add_filter('woocommerce_account_orders_columns', 'remove_defualt_order_number_column', 10, 1);
add_action('woocommerce_my_account_my_orders_column_order-number-custom', 'add_custom_order_number_column', 10, 1);
function add_custom_order_number_column($order) {
echo esc_html(_x('#', 'hash before order number', 'woocommerce') . $order->get_order_number());
}