I want to rename the WooCommerce’s “order” label in admin and email to something else.
I want to use “Booking” as replacement for “order”
I have a custom code snippet to do this but couldn’t work, yet broke down the site and have fatal error.
Here’s the code I tried!
<?php
// Change "Order" to "Booking" in the admin menu
function change_order_to_booking_admin_menu() {
global $menu;
global $submenu;
foreach ($menu as $key => $value) {
if ($menu[$key][0] == 'Orders') {
$menu[$key][0] = 'Bookings';
}
}
if (isset($submenu['edit.php?post_type=shop_order'])) {
foreach ($submenu['edit.php?post_type=shop_order'] as $key => $value) {
if ($submenu['edit.php?post_type=shop_order'][$key][0] == 'Orders') {
$submenu['edit.php?post_type=shop_order'][$key][0] = 'Bookings';
}
}
}
}
add_action('admin_menu', 'change_order_to_booking_admin_menu', 999);
// Change "Order" to "Booking" in post type labels
function change_order_to_booking_post_type_labels( $labels ) {
$labels->name = 'Bookings';
$labels->singular_name = 'Booking';
$labels->add_new = 'Add Booking';
$labels->add_new_item = 'Add New Booking';
$labels->edit_item = 'Edit Booking';
$labels->new_item = 'New Booking';
$labels->view_item = 'View Booking';
$labels->search_items = 'Search Bookings';
$labels->not_found = 'No Bookings found';
$labels->not_found_in_trash = 'No Bookings found in trash';
$labels->all_items = 'All Bookings';
$labels->menu_name = 'Bookings';
$labels->name_admin_bar = 'Booking';
return $labels;
}
add_filter('woocommerce_register_post_type_shop_order', 'change_order_to_booking_post_type_labels');
// Change email subject and heading
function change_order_to_booking_email_subject( $subject, $order ) {
$search = array( 'Order', 'order' );
$replace = array( 'Booking', 'booking' );
return str_replace( $search, $replace, $subject );
}
add_filter('woocommerce_email_subject_new_order', 'change_order_to_booking_email_subject', 10, 2);
add_filter('woocommerce_email_subject_customer_processing_order', 'change_order_to_booking_email_subject', 10, 2);
add_filter('woocommerce_email_subject_customer_completed_order', 'change_order_to_booking_email_subject', 10, 2);
function change_order_to_booking_email_heading( $heading, $email ) {
$search = array( 'Order', 'order' );
$replace = array( 'Booking', 'booking' );
return str_replace( $search, $replace, $heading );
}
add_filter('woocommerce_email_heading_new_order', 'change_order_to_booking_email_heading', 10, 2);
add_filter('woocommerce_email_heading_customer_processing_order', 'change_order_to_booking_email_heading', 10, 2);
add_filter('woocommerce_email_heading_customer_completed_order', 'change_order_to_booking_email_heading', 10, 2);
New contributor
Abey Tough is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.