Created
July 4, 2017 14:35
-
-
Save doubleedesign/60eff0f88a6cd3c67948671604eb4d7d to your computer and use it in GitHub Desktop.
Function to add a list of item descriptions to WooCommerce order confirmation emails
This file contains 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
<?php | |
// Add item descriptions to order confirmation emails | |
function doublee_add_purchase_details($order_id) { | |
echo '<h2>Item details</h2>'; | |
echo '<ul>'; | |
$order = wc_get_order($order_id); | |
foreach ($order->get_items() as $item) { | |
$product_id = $item['product_id']; | |
$product = get_post($product_id); | |
echo '<li>'; | |
echo '<strong>' . $product->post_title . ': </strong><br/>'; | |
/* use this if you want the formatted version of the post_content, not plain text: | |
$product_details = apply_filters( 'the_content', $product->post_content); */ | |
$product_details = strip_tags($product->post_content, '<strong>'); | |
echo $product_details; | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} | |
add_action( 'woocommerce_email_customer_details', 'doublee_add_purchase_details'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment