Created
April 6, 2020 01:24
-
-
Save the-sufi/53144805c9fd22d138710020bf05cdf2 to your computer and use it in GitHub Desktop.
WooCommerce - show coupon code & description in order email
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 | |
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