WooCommerce Show Product Total Quantity

Product Total Quantity

If customers add quite a lot products to cart, when they view the cart, they are difficult to find out total how many they added to cart.

Or, if there is a situation: Purchase any product, get 20% discount if more than 100 pieces. Customers need to know how many they have added to cart.

Here is the coding to show total how many products added to cart:

<?php global $woocommerce; ?>
<?php echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?>

I added the coding before Cart Subtotal, you may add to any place you want.

<tr class="cart-subtotal">
	<th><?php _e( 'Product Quantity', 'woocommerce' ); ?></th>
	<td><?php global $woocommerce; ?><?php echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?></td>
</tr>

Show in Cart Page

To show the total quantity in cart page, you need to copy /plugins/woocommerce/templates/cart/cart-totals.php to your child theme /woocommerce/cart/ to prevent any error.

Result:
WooCommerce Show Product Total Quantity

Show in Checkout Page

To show the total quantity in checkout page, you need to copy /plugins/woocommerce/templates/checkout/review-order.php to your child theme /woocommerce/checkout/ to prevent any error.

Result:
WooCommerce Show Product Total Quantity Checkout Page

External Link: WooCommerce – Show number of items in cart and total

WooCommerce Show Product Total Quantity
Please do hesitate to contact me if you found out any mistake or typo.

2 Comments

Leave a Comment.

Time limit is exhausted. Please reload CAPTCHA.