Magento 2: Show total items count in Knockout template
-
10-10-2020 - |
Question
I want to display the total items count using Knockout, in Magento_Checkout::header/minicart.phtml
, e.g. if I have 2 items with the same SKU in the basket then the total items count is 1.
I have tried using data-bind="text: getCartParam('items_count')"
but this returns the total quantity (i.e. 2).
I could use <?php echo $this->helper('\Magento\Checkout\Helper\Cart')->getItemsCount(); ?>
but I'd like to try and use a Knockout binding instead - is this possible?
OTHER TIPS
you can use like this in template file
<span class="number"><!-- ko text: cartSidebar().items.length --><!-- /ko --></span>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange