i looking everywhere, but not found this functions, i need to calculate the total items in the report email new order,i think is (admin-new-order.php) so i need to see the numbers total products in the under row on subtotal or elsewhere

enter image description here

Item                       Price                       Quantity             
Product A                      $10                         4                
Product B                      $5                          1      
Product C                      $15                         2                 

Cart Totals

Cart Subtotal       $30
Count products      7 <---
Shipping Cost       $12

Order Total         $42

How i do ? Help..me..

1 Answer 1


You could call either of the following functions in your email template:

<?php echo WC()->cart->get_cart_contents_count(); ?>


<?php echo(count(WC()->cart->get_cart())); ?>
  • from functions.php its possible?
    – Exolon
    Feb 5, 2021 at 19:14
  • You wanted to do it in your email template right? Use them in your email template/any page template that you want. There is no point in echoing them in functions.php, you could use them in functions.php though but you don't need to! Echo them in your theme templates.
    – Ruvee
    Feb 5, 2021 at 19:19
  • ok i now try, but there is also the possibility to add from functions.php?
    – Exolon
    Feb 5, 2021 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.