Forked from woogists/wc-custom-checkout-field-display-in-emails.php.php
Created
October 3, 2020 19:10
-
-
Save bobwol/dca1c509e5c4f86e5d31fd685e9b28d7 to your computer and use it in GitHub Desktop.
[Customizing checkout fields using actions and filters] Add custom WooCommerce checkout field to emails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* To use: | |
| 1. Add this snippet to your theme's functions.php file | |
| 2. Change the meta key names in the snippet | |
| 3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg | |
| 4. When next updating the status, or during any other event which emails the user, they will see this field in their email | |
| */ | |
| add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys'); | |
| function my_custom_order_meta_keys( $keys ) { | |
| $keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails | |
| return $keys; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment