Получить количество товара в корзине

WC()->cart->get_cart_contents_count() – it allows to get a number of cart items including their quantity counts. For example, if you have 10 snowboards and 1 avocado toast in the cart, this method will return 11! You can see it yourself if you open this method in WooCommerce source code. It just gets the whole cart array from WC()->cart->get_cart() and then for each item it gets its quantity parameter.
count( WC()->cart->get_cart() ) – this implementation actually returns the number of unique products in the cart, one per product.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

*

code