Customizing product names in WooCommerce invoices allows businesses to personalize customer interactions and highlight key products. Using a simple code snippet; store owners can display unique product names for specific products or users, ensuring greater flexibility and clarity in invoices. This customization is especially useful for branding, promotional strategies, and enhancing the customer experience. This customization is possible with WebToffee’s WooCommerce PDF Invoices, Packing Slips, and Credit Notes plugin.
Adding a custom code snippet to a WordPress site
Below are the steps for the same:
- Make necessary alterations to the code snippet by selecting the required case discussed below.
- Add the altered code snippet to your WordPress site. You can add the snippet to your current theme’s functions.php file or use a third-party plugin for the addition. To know more, check out the following article: Adding Custom Codes with a Third-Party Plugin.
Code snippet for displaying a different product name on invoices
Case 1: Showing a unique product name for a specific product on invoices
Below are the steps for the same:
- From the WordPress dashboard, navigate to Products > All Products. Hover over the required product and find its product ID.
- In the custom code snippet, replace the default product ID with the required product ID. For example, replace
$target_product_id = 1186;
with$target_product_id = 68;
where 68 is the required product ID. - In the custom code snippet, add a unique name for the specific product under
$order_item_name = "new product name for specific product";
This unique name will appear for the product in invoices.
The image below shows the custom code snippet after making the above alterations.
The images below show WooCommerce invoices for an order before and after adding the custom code snippet.
Case 2: Showing a unique product name for a specific user on invoices
Below are the steps for the same:
- From the WordPress dashboard, navigate to Products > All Products. Hover over the required product and find its product ID.
- From the WordPress dashboard, navigate to Users > All Users. Click on the Edit option of a user. You can now find the user ID within the URL as shown below.
- In the custom code snippet, replace the default product ID and user ID with the required product ID and user ID. For example, replace
$target_product_id = 1186;
with$target_product_id = 68;
also replace$target_user_id = 0;
with$target_user_id = 4;
where 68 is the product ID, and 4 is the user ID. - Add a unique name for the specific product under
$order_item_name = "new product name for specific user for a specific product";
- Add the original product name under
$order_item_name = "new product name for specific product";
so that the original product name appears for all other users.
The image below shows the custom code snippet after making the above alterations.
The images below show WooCommerce invoices for orders placed by a regular user and a specific user.