Get product item quantity added to cart
-
Hello I’m trying to display the number of items added to cart in Woocommerce.
Every time a specific quantity of items is added to cart, Woocommerce adds it to the message (i.e. “4 x Tshirts are added to your cart). I would need to display this value inside a custom message. I tried to use:global $woocommerce; foreach ( WC()->cart->get_cart() as $cart_item ){ $item = $cart_item['data']; //print_r($item); if(!empty($item)){ $product = new WC_product($item->id); $quantity = $item->get_quantity; echo $quantity; } }
echoing it but nothing is displayed.
How can I get that specific value?
Thank you in advance!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get product item quantity added to cart’ is closed to new replies.