Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doubleedesign/60eff0f88a6cd3c67948671604eb4d7d to your computer and use it in GitHub Desktop.
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
<?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