Capture Quantity of Items in Cart Wordpress

Asked

Viewed 1,522 times

3

I wonder what is the best way to capture the amount of items in the Woocommerce cart in Wordpress, if there are any shortcode, etc.

  • I can help you, but I need to ask you a few questions: Do you want the numerical amount of each customer, in the act of your requests or want the overall total?

  • In the case, overall total, by the following, in my idea, the shopping cart icon will be on the upper right side of the website and indicating the number of items in the cart.

1 answer

2


To show in your template the total use this:

<?php 

    global $woocommerce;
    $numero = sprintf(_n('%d', $woocommerce->cart->cart_contents_count, 'woothemes'));

    echo $numero;

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.