Print the unit price in the emails

, ,

Some months ago I wrote a post about how to add the unit price in the checkout page.
It would be useful though to have the same unit price also in the emails sent both to the admin and to the customer.

Doing this it’s harder than what we did for the checkout page.
There are more templates to tweak and we also have to consider both plain and HTML emails.

But it’s not impossible, obviously.

Download “Unit price in the emails”

emails.zip – Downloaded 3272 times – 7.79 KB

Download the zip above, then extract it. You will have a folder names emails in your computer. Copy that folder and put it in wp-content/themes/your-theme-name/woocommerce/.

Note: If you are using a custom theme which already overrides the emails templates be careful. This may break your theme. Contact the theme author before to override the templates.

Download “Unit price in the emails”

emails.zip – Downloaded 3272 times – 7.79 KB

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me writing more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$100.00
$5.00
$15.00
$100.00
$5.00
$15.00
$100.00

Or enter a custom amount

$

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

Do you prefer using cryptocurrency? I’ve got you covered! You can donate at the following wallets:

  • BTC: bc1q87nxpdpqw323ccmerrzyeffs72wnxpw93x7pzk / 17Gtc5e8yoh2LZzokoyK8P5DWbToBwztok
  • ETH: 0xA5C89Be1df2896C3942DBEf751cCeacC7929388b

66 replies
      • Crystal
        Crystal says:

        I’m sorry, it was in the woocommerce-quotation plugin. I had to add in an

        After that worked and was in the correct order.

        Thank you for your help, this should really be part of Woocommerce as a default function. It just makes sense.

        Reply
    • Nicola Mustone
      Nicola Mustone says:

      HI Viviana,
      Sorry for the very late reply!

      Technically yes, it is possible. You need to add the code to print the number. I’m not sure what to add because it depends on the Invoicing plugin you are using.

      Reply
  1. Rob
    Rob says:

    Hi Nicola, it’s not working for me unfortunately.
    I’ve put the file in the child-theme/woocommerce folder and then in the maintheme/woocommerce folder – both extracted of course!
    Not sure what I’m doing wrong unless this fix if pre Woocommerve 2.5?
    I have WC 2.5.5

    Reply
    • Nicola Mustone
      Nicola Mustone says:

      Hi Rob,
      I just tested this on WooCommerce 2.6.1 and it works. I guess it works also for the 2.5 since the templates are the same!

      Make sure that you are pasting the whole emails folder in child-theme/woocommerce/, and not only the files inside the folder.

      Reply
  2. Hove
    Hove says:

    its great …Thanks for this . i have the same issue as Crystal . the columns are switched. quantity has the prices and the Price column has the quantities..
    it will great if get the fix .
    thanks . HOve

    Reply
  3. Laura
    Laura says:

    Does this work with WooCommerce 3.6.6? I am nervous about replacing the “whole folder” since your folder has about half the .php files as the current version.

    Reply
    • Nicola Mustone
      Nicola Mustone says:

      Hi Laura,
      Thanks for reporting. I’ll have to update the templates, but the difference is very small. I simply add a new row in the table. You can open the files from my zip, copy the differences and add them to your templates from the 2.6.6.

      I’ll update the zip in this article as soon as I can.

      Reply
  4. Lyse Tremblay
    Lyse Tremblay says:

    Hi Nicola,

    Thank you so very much for sharing. It works very nicely. However, if an order is fails, I need also the customized order table. Do you have a updated file for this condition that you could share?

    In addition to that, is there an easy way to add a block of text at the top to include the seller company contact information and to move the customer details above the order items table?

    Regards
    Lyse

    Reply
  5. haris
    haris says:

    hello..
    Can someone tell me how I can translate the title Unit Price after insert the file?
    Thank you in advance.
    Haris

    Reply
  6. Lyse
    Lyse says:

    Hi Nicola,

    With WooCommerce v3.0, two templates were modified: email-order-items.php one located in the emails folder the other in the plain folder.

    Are you planning to update your templates to WC version 3.0? That would be very nice.

    Thanks
    Lyse

    Reply
  7. Lyse
    Lyse says:

    Hi Nicola,

    Please let me know when they are ready for download. Thank you for responding quickly.

    Lyse

    Reply
  8. Lyse
    Lyse says:

    Hi Nicola,
    I have to upgrade to WooCommce v3.0 now, so I looked at updating the two templates myself but one of them is giving grief because the new version appears to be stripping tags which your template has and I’m not knowledgeable enough to understand the implications and risk I would be taking guessing what these will do or counter react.

    Any ETA as to when you would have the time to look at these two templates only? The more difficult one for me is the the file in the plain folder.

    Much appreciated
    Lyse

    Reply
  9. Koray
    Koray says:

    Hello I’m using custom plugin for email templates (Email costomizer) how can I add price per unit in my email template?
    THANKS!

    If you want I can send you the template to see if you can

    Reply
  10. Lyse
    Lyse says:

    Hi Nicola,
    I have upgraded to WooCommerce v3.2.1 now, and it looks like three templates have been updated. I was wondering if you could update your templates to reflect the new WooCommerce changes. The templates that have changed are:

    woocommerce/emails/email-order-details.php version 3.0.0 is out of date. The core version is 3.2.0,
    woocommerce/emails/email-order-items.php version 3.0.0 is out of date. The core version is 3.2.0,
    /woocommerce/emails/plain/email-order-items.php version 3.0.0 is out of date. The core version is 3.2.0

    I had a look at updating these myself but I’m a little confused with the new changes.

    Any ETA as to when you would have the time to look at these templates?

    Much appreciated
    Lyse

    Reply
  11. Mike
    Mike says:

    Is there a way to not add discount to the unit price? When I have a discount it shows discount applied instead of just unit price.

    Reply
  12. Vicky
    Vicky says:

    Thank you so much for this, I have been trying to solve this issue for a client for a few weeks now with no joy.
    This worked fantastic, I had to make a small adjustment as the subtotals, tax etc where showing in col 2 which looked untidy so simply changed this to col 3 to achieve.
    Thanks again!!

    Reply
  13. Ander
    Ander says:

    Thank you so much. Working on WP 4.9.

    Only 1 thing:

    In the total, and shipping mode columuns has to be colspan=”3″

    <th class=”td” scope=”row” colspan=”3″”>

    Reply
  14. Lyse
    Lyse says:

    Hi Nicola
    There is now a revised 3.4.0 version of the email-order-items.php and yours is still at version 3.2.0 after I download it.

    Do you have an update of your files available download?

    Thanks
    Lyse

    Reply
  15. Roland
    Roland says:

    Oh man you just saved my day! I was looking for something like this for about 2 days straight.
    Downloaded the files and uploaded them to the right folder and it works right away. Only thing i had to change was the column thing, but that was easy enough..

    BTW since today (nov, 1st) the template is out of date since there’s a 3.5.0 core version, I didn’t test if it’s still working, but i thought i let you know!

    Reply
  16. Lyse
    Lyse says:

    Hi Nicola,

    I just noticed in the last month that some product images display in the emails and sometimes they don’t. I’ve talked to a WooCommerce support representative about this and because I use customization, they can’t provide support on this issue.

    Here’s the code used in the “order-email-details.php” file:

    tbody
    ?php
    echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
    ‘show_sku’ => $sent_to_admin,
    ‘show_image’ => false,
    ‘image_size’ => array( 32, 32 ),
    ‘plain_text’ => $plain_text,
    ‘sent_to_admin’ => $sent_to_admin,
    ) ); ?
    /tbody

    Can you help with my issue of the product images not displaying in emails?

    Thanks
    Lyse

    Reply
  17. JJBjani
    JJBjani says:

    Hello from me. I tried to use your files try to print Unit price in order emails. In the middle of the table where was written the products, the info for price appear, but in header of the table and in footer with totals – no changes! Where must be the problem?

    Reply
  18. marianne
    marianne says:

    Hello Nicola,
    Great changes in the order-details and items.
    Just what I needed.
    Unfortunately I get some html code in the emails. Like also some extra spacing in the unit price and a ; symbol in the price.
    Any idea where I should look?

    Reply
  19. Todd Brien
    Todd Brien says:

    Thank you for your code, but we are using WP 5.2 and Woocommerce 3.6.4 and under “Unit Price” all we get is $0.00.
    Does your code work with these versions?

    Thank you,
    Todd

    Reply
  20. Todd Brien
    Todd Brien says:

    I don’t know if you are still monitoring this blog, but if you are we would be more than happy to pay you for a solution to our needs!!!!!!!!!!!

    Thank you for your code, but we are using WP 5.2 and Woocommerce 3.6.4 and under “Unit Price” all we get is $0.00.
    Does your code work with these versions?

    Thank you,
    Todd

    Reply
  21. James
    James says:

    Thanks for this! really helpful.
    But is there a way to show the unit price as tax included price?
    As of now each product unit price on the 2nd column shows tax excluded price and subtotal on the last column is included.

    Reply
    • James
      James says:

      Nevermind. I figured it out!
      In case someone run into same issue as me,
      Instead of using
      <?php echo wc_price( $order->get_item_total( $item, false, true ) at line 67,
      replace ‘false’ after $item to ‘true’ to get tax included value.
      <?php echo wc_price( $order->get_item_total( $item, true, true )

      Reply
  22. Manuel
    Manuel says:

    Hi there! that is amazing and should be a standard setup from woocommerce. You are great. Quick question: Do your files still work now in 2019 or are the templates outdated?

    Reply
  23. Vitalii
    Vitalii says:

    hello! Thanks for help. Maybe you can tell how can I manage order? q-ty, unit price, price
    I can manage table heading, not email array

    Reply
  24. Junaid
    Junaid says:

    Would be great if you could explain what’s done in the files! I could not figure it out. Does it just work by adding the column I haven’t been able to see the code that `echo` the value. Thank you!

    Reply
  25. Gibran
    Gibran says:

    I’ve tried it and it works but WP throws back a notification that the templates need to be updated. Anyone else get that? Is there an updated template?

    Reply
  26. Emanuel
    Emanuel says:

    Hi, I am using your files, it works just great but it is displaying the price without tax and I need to have the unit price shown+VAT. Can you help me?

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply