Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save the-sufi/53144805c9fd22d138710020bf05cdf2 to your computer and use it in GitHub Desktop.
Save the-sufi/53144805c9fd22d138710020bf05cdf2 to your computer and use it in GitHub Desktop.
WooCommerce - show coupon code & description in order email
<?php
function dctit_add_coupon_to_email( $order ) {
$coupons = $order->get_items('coupon');
foreach ($coupons as $item_id => $item) {
$coupon = new WC_Coupon( $item['name'] );
$post = get_post($coupon->id);
echo "<p class='coupon-used'><span class='coupon-name'><b>Coupon: " . $item['name'] . "</b></span></p>";
echo "<p><span class='coupon-description'>" . $post->post_excerpt . "</span></p>";
}
}
add_action( 'woocommerce_email_after_order_table', 'dctit_add_coupon_to_email', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment