Skip to content

Instantly share code, notes, and snippets.

@elias1435
Created August 17, 2023 15:47
Show Gist options
  • Save elias1435/cf1ec6f0df33791b3b6056447d3f78df to your computer and use it in GitHub Desktop.
Save elias1435/cf1ec6f0df33791b3b6056447d3f78df to your computer and use it in GitHub Desktop.
How to display acf product field in woocommerce order email. ACF field name is 'customer_email' and its location is product. blow code will go to functions.php
add_action( 'woocommerce_order_item_meta_end', 'custom_product_info', 20, 4 );
function custom_product_info ( $item_id, $item, $order, $plain_text ) {
$id = $item->get_product_id();
$product_info = get_field('customer_email',$id);
if($product_info){
echo "<p>Customer Message: $product_info</p>";
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment