Advertisement
thesufi

Woocommerce - show coupon code & description in order email

Feb 23rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. //add coupon details in order email
  2. add_action( 'woocommerce_email_after_order_table', 'wc89790_add_coupon_to_email', 20 );
  3. function wc89790_add_coupon_to_email( $order ) {
  4.     $coupons = $order->get_items('coupon');
  5.    
  6.     foreach ($coupons as $item_id => $item) {
  7.         $coupon = new WC_Coupon( $item['name'] );
  8.         $post = get_post($coupon->id);
  9.         echo "<p class='coupon-used'><span class='coupon-name'><b>Coupon: " . $item['name'] . "</b></span></p>";
  10.         echo "<p><span class='coupon-description'>" . $post->post_excerpt . "</span></p>";
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement