How to Hide Customer IP Address on the WooCommerce Order Page ?2 min read
Reading Time: 2 minutesBy default, WooCommerce displays the customer IP address on the order page in the WordPress dashboard. This can be a privacy concern for some store owners who want to hide this information from their staff members. In this article, we will show you how to hide the customer IP address on the WooCommerce order page using a simple code snippet.
Step 1: Create a Child Theme
Before we can modify the code to hide the customer IP address, we need to create a child theme. This is because modifying the core WooCommerce files directly is not recommended, as any changes made will be overwritten during a plugin update. You can skip below step if already have a child theme
To create a child theme, follow these steps:
- Create a new folder in the /wp-content/themes/ directory and name it anything you like (e.g., mytheme-child).
- Inside the new folder, create a new file named style.css.
- Add the following code to the style.css file:
/*
Theme Name: My Theme Child
Theme URI: https://example.com/my-theme-child/
Description: Child theme for My Theme
Author: John Doe
Author URI: https://example.com/
Template: my-theme
Version: 1.0.0
*/
Note: Replace “My Theme” with the name of your parent theme.
Save the style.css file.
Step 2: Add Code Snippet to hide IP (woocommerce order page)
After creating a child theme, we can add the following code snippet to the functions.php file to hide the customer IP address on the order page:
/**
* Hide customer IP address on the order page
*/
add_filter( 'woocommerce_order_get_customer_ip_address', 'my_custom_ip_address', 10, 2 );
function my_custom_ip_address( $ip_address, $order ) {
// Modify the IP address here
$new_ip_address = '';
// Return the new IP address or an empty string to remove it
return $new_ip_address;
}
Simply add the code snippet to the functions.php file of your child theme and save it.
Step 3: Verify Changes
After adding the code snippet, refresh the order page to verify that the customer IP address is no longer displayed.