WooCommerce: display coupons used in an order in the confirmation email and on the edit page

Here is a nice snippet that i really like. It will allow you to show the coupon codes used in order on the order edition page, and on the confirmation email. The snippet provides two functions, one for each action, and using the following hooks woocommerce_email_after_order_table and woocommerce_admin_order_data_after_billing_address. Then, the code is pretty much the same, it uses get_used_coupons() to retrieve coupon code. Here is the result in the administration:


Simply add this snippet to the file called functions.php within your theme folder:

About the author

Remi Hey! My name is Rémi Corson, I'm a French WordPress Developer, I code stuff and I write from time to time ;-) Buy a coffee
Show your support

Related Posts


  1. […] to check out for some small but useful modifications. He also wrote an interesting tidbit on adding coupons to your order emails for WooCommerce as […]

  2. AlfalfaAnne:

    Hi Remi,

    This is fantastic! Do you know if there is a way to add a coupon code to an order through the dashboard admin area (for example, creating manual orders)?

    I’ve found this link (http://stackoverflow.com/questions/19551694/woocommerce-need-hook-when-admin-manually-creates-order), but is there a way to hook this in with a custom field maybe?

    I’ll keep muddling through, but I thought it might pique your interest.


  3. westcoast:


    I’ve been looking all over the web and doing testing for hours trying to figure this out. You would think woocommerce would have this figured out but I can’t get their own code to work: http://docs.woothemes.com/document/send-coupons-used-in-an-order-by-email

    Anyway, thanks again!

  4. theswine:

    Great snippet.

    We are in need of the same thing on the PDF printable invoice ??

    It doesn’t show the coupon code, just the dollar off amount ?

    Any way to show the coupon code on the “PDF Invoice” that we print ??

    Thanks so much NINJA!

  5. Pippa:

    Dear Remi,

    is there a way to display the specific name of the used coupon in order details and customer emails?

    Kind regards!

  6. elliot:

    This is fantastic work Remi – Should be core!

  7. timmathews:

    Hi Remi, I’m Tim. Just found your site and I love it, but I still can’t find what I need and maybe you can assist.
    We did a groupon type deal, issued 1k coupon codes and sold 400.
    Problem is, I don’t want to scroll through 60 pages of coupons to try to find the ones that are used. Is there a way to sort the coupons? Say, click the “usage / limit” head and it will sort? This way, I can go to the first pages and see the 331/*, the 1/1 coupons then eventually come to the 0/1 coupons.
    Any help or ideas?
    Thank you in advance,

  8. macttu:

    Hey Remi,

    I’m new to your site and somewhat of a newb to WooCommerce and WordPress. I have added your “show username” snippet to the functions.php and it worked perfectly………when I try to add this code to the bottom of my functions.php, the code shows up above the header on my site(AggielandVIP.com).

    Would there be a specific location on the functions.php where I should put this? I’ll order a $5 item if you can help me get this implemented as it would be a great addition to my site!

    Thanks in advance for any help you can provide keep up the great work!


  9. softagon:


    How can i put a upload field on admin order? I want to try this, but didn’t worK http://pastebin.com/20ap9ss0

  10. ansleyRDgroup:

    How do we get this on the “processing order” (customer receipt) email? Your code works great for the Order management/edit screen and the coupon is included in the “new order” email but it does not appear in the customer receipt (what woocommerce labels as the “processing order email”)

    Thank you and great post!
    Jason Ansley
    Full Service Business Development Concierge, Coaching, & Consultancy

  11. schalkjoubert:

    Hi Remi,

    Is it possible to add a coupon code to the Order edit Page?


    • schalkjoubert:

      To explain further;
      At times the site admin need to complete an order which is placed telephonically, for someone that already has a customer account.
      It is just so much simpler to do it from the backend.

  12. Collin:

    This doesn’t appear to work with WooCommerce 2.6+. After I add this to my theme’s custom functions PHP file I don’t see an errors but nothing new appears in the “new order” admin emails. Any chance you can update the code, Remi?

  13. iengage365:

    Hi, is there anyway to ad script to the code to populate a custom field against the order so when we export the order record with the coupon cold also?


  14. surbhi2991:

    I have activated WooCommerce in my site for the first time, & i have a question.
    I want to display Applied Coupon Code in Email Template Which is sending to Admin on Every New Order Placement.
    Let me know which file or which code i need to apply for this situation.
    Main query is i have to do this using another plugin, so can you tell me how to access New Order Email template in another plugin and add applied coupon code in email template then send mail.


  15. jacobus:

    Could the value of the discount code also be shown in the text output?

Leave a Reply