WooCommerce: display coupons used in an order in the confirmation email and on the edit page
Posted on
This might be outdated!
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
Related Posts
23 comments
Leave a Reply
You must be logged in to post a comment.
[…] 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 […]
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.
Thanks!
Remi,
THANK YOU!
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!
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!
hooking the custom_checkout_field_display_admin_order_meta() function to the proper filter in the PDF invoice should work (however i don’t have it in mind!)
Hello Remi, can you elaborate further on this please? Do you mean adding something like this in PDF Invoice Template’s Template.php?
[[CouponCode]]
Please advice :(
Dear Remi,
is there a way to display the specific name of the used coupon in order details and customer emails?
Kind regards!
Hmmmm… isn’t it what the code does?
Hello Remi,
haven’t expressed myself clearly. I mean the part of the order table disyplayed in customer emails under the row “subtotal”.
This is fantastic work Remi – Should be core!
Thanks Elliot!
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,
Tim
Or even sort the coupons by used / not used? I like sorting things and this would make life simple!
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!
Mac
Hello,
How can i put a upload field on admin order? I want to try this, but didn’t worK http://pastebin.com/20ap9ss0
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
ansleyRDgroup
Full Service Business Development Concierge, Coaching, & Consultancy
Hi Remi,
Is it possible to add a coupon code to the Order edit Page?
Thanks
Schalk
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.
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?
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?
Thanks
Mark
Hi,
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.
Thanks.
Could the value of the discount code also be shown in the text output?
Could the amount be added? This would be the discount value calculated by applying the coupon just for clarification.