Help with custom field in order email
-
Hello
I’m working on making changes to the order completed email to add a custom field. I created a custom field for entering a URL associated with certain products. I’ve already copied the correct email template to my theme and understand how to modify that, what I am looking for help with is getting my code down.This is the code I have so far to display the custom field:
<?php $post->ID = 41;?> <?php echo esc_html(get_post_meta($post->ID, 'Access URL', true));?>
NOTE: ‘Access URL’ is the name of the custom field.
I have two questions:
1. Can someone tell me which variable woocomerce uses to store the product ID? In the above code I have to specify the product ID manually but I want to get the ID based on the product the email is being generated for so it will apply to any product?2. I’d like to only display this in the email for products that have a value for that particular custom field. Could someone show me the code to test if there is a value for that field and if so display it or if there is no value in the given product for that field to omit the display?
thanks
- The topic ‘Help with custom field in order email’ is closed to new replies.