This snippet allows you to change the product name after the purchase has been made. Let’s say for example you are selling adult products or services and the customer doesn’t want these shown on the emails. Well this snippet will replace the product name meaning they see an admin defined string rather than the product name. The new string will be shown on the thank you page, emails, and my account order view. However, the admin will still see the actual product name in the admin dashboard.
/**
* Snippet Name: WooCommerce Change Product Name After Purchase
* Snippet Author: ecommercehints.com
*/
add_filter( 'woocommerce_order_item_name', 'ecommercehints_change_product_name_after_purchase', 20, 3 );
function ecommercehints_change_product_name_after_purchase( $item_name, $item, $is_visible ) {
$item_name = 'Full English Breakfast';
return $item_name;
}